TBL Codes
306 subscribers
6 photos
2 files
46 links
Download Telegram
๐Ÿ’ก Telegram Tip: Image Cache!

When you send images by URL, Telegram caches them on their CDN.
That means if you update the image on your server, Telegram wonโ€™t fetch the new version automatically.

โœ… Fix: Add a random query parameter to the URL:
https://example.com/photo.png?v=12345

This forces Telegram to download the latest version every time.
Forwarded from Krishna ~
Force Channel Join Tbh Code

Command /start

Code:
await Api.sendMessage({
chat_id: chat.id,
text: "*Please join our channel to continue.*\n\n_Join first, then tap โ€œI Joinedโ€._",
parse_mode: "Markdown",
reply_markup: {
inline_keyboard: [
[{ text: "Join Channel", url: "https://t.me/Mrnull9" }],
[{ text: "I Joined", callback_data: "check_join" }]
]
}
});


Command check_join

Code:

let channels = ["@Mrnull9"];
let res = await Libs.mcl.check(user.id, channels);

let mid = request.message.message_id;

if (res.all_joined === true) {
Api.editMessageText({
chat_id: chat.id,
message_id: mid,
text: "*Verification Complete!*\n\n_You may continue now._",
parse_mode: "Markdown"
});
} else {
Api.editMessageText({
chat_id: chat.id,
message_id: mid,
text: "*You have not joined yet.*\n\n_Please join first, then tap โ€œCheck Againโ€._",
parse_mode: "Markdown",
reply_markup: {
inline_keyboard: [
[{ text: "Join Channel", url: "https://t.me/Mrnull9" }],
[{ text: "Check Again", callback_data: "check_join" }]
]
}
});
}

Credit & Devloped By: @Raghav768
Telegram Channel:
@MrNull9
โค4๐Ÿ”ฅ1
Krishna ~
Force Channel Join Tbh Code Command /start Code: await Api.sendMessage({ chat_id: chat.id, text: "*Please join our channel to continue.*\n\n_Join first, then tap โ€œI Joinedโ€._", parse_mode: "Markdown", reply_markup: { inline_keyboard: [ โ€ฆ
Little Upgraded version


command: @
const channels = [
  "@Mrnull9"
]


command: /start
const ik = [];

for (const c of channels) {
  ik.push([
    {
      text: "Join to " + c,
      url: "tg://resolve?domain=" + c.slice(1)
    }
  ]);
}

ik.push([
  {
    text: "I Joined",
    callback_data: "check_join"
  }
]);

Api.sendMessage({
  text: "Please join our channel to continue.*\n\n_Join first, then tap โ€œI Joinedโ€._",
  reply_markup: {
    inline_keyboard: ik
  }
});


command: check_join
const ik = []; // again???
const res = await Libs.mcl.check(user.id, channels);
const allJoined = res.all_joined;

const text = allJoined
  ? "*Verification Complete!*\n\n_You may continue now._"
  : "*You have not joined yet.*\n\n_Please join first, then tap โ€œCheck Againโ€._";

for (const c of channels) {
  ik.push([
    {
      text: "Join to " + c,
      url: "tg://resolve?domain=" + c.slice(1)
    }
  ]);
}

ik.push([
  {
    text: "Check again",
    callback_data: "check_join"
  }
]);

Api.editMessageText({
  text,
  message_id: request?.message?.message_id,
  parse_mode: "Markdown",
  reply_markup: {
    inline_keyboard: !allJoined ? ik : undefined
  }
});



By : @vinadira
๐Ÿ”ฅ2โค1
Forwarded from TECH CODER
Example of using emoji effect

Command - /start
Api.sendMessage({
    chat_id: user.telegramid,
    text: "๐ŸŽ‰ Celebration effect message",
    parse_mode: "Markdown",
    message_effect_id: "5046509860389126442"
});



'๐Ÿ”ฅ': "5104841245755180586",
'๐Ÿ‘': "5107584321108051014",
'๐ŸŽ‰': "5046509860389126442",
'๐Ÿ‘Ž': "5104858069142078462",
'โค๏ธ': "5044134455711629726",
๐Ÿ”ฅ6
โญ TBL Tip: Use Any Telegram API Method Dynamically!

If a method isnโ€™t available in TBLโ€™s Api.xxx, you can still call it:

Api.call("methodName", { /* params */ })

Example:
Api.call("getChat", {
chat_id: -1007657565746
})

Use any new Telegram method instantly ๐Ÿš€
Docs: https://telebothost.com/docs/#api-dynamic
Link shortner TBL codes

Command: /short
Use: /short <long_link>

TBL code:

/* Command: /short */

if (!params) {
Api.sendMessage({
chat_id: chat.id,
text:
"โŒ <b>Missing URL</b>\n\n" +
"๐Ÿ‘‰ <b>Usage:</b>\n" +
"<code>/short https://example.com</code>\n\n" +
"Please send a valid long link.",
parse_mode: "HTML"
})
return
}

let longUrl = params.trim()

if (!longUrl.startsWith("http://") && !longUrl.startsWith("https://")) {
Api.sendMessage({
chat_id: chat.id,
text:
"โŒ <b>Invalid URL</b>\n\n" +
"URL must start with:\n" +
"<code>http://</code> or <code>https://</code>",
parse_mode: "HTML"
})
return
}

Api.sendChatAction({
chat_id: chat.id,
action: "typing"
})

let res = await HTTP.get({
url: "https://tinyurl.com/api-create.php",
query: { url: longUrl }
})

if (!res || !res.content) {
Api.sendMessage({
chat_id: chat.id,
text:
"โš ๏ธ <b>Failed to shorten the link</b>\n" +
"Please try again later.",
parse_mode: "HTML"
})
return
}

Api.sendMessage({
chat_id: chat.id,
text:
"โœจ <b>URL Shortened Successfully!</b>\n\n" +
"๐Ÿ”— <b>Short Link:</b>\n" +
"<code>" + res.content + "</code>\n\n" +
"๐Ÿš€ Powered by <b>TinyURL</b>",
parse_mode: "HTML"
})

Powered by Tinyurl

๐Ÿš€ Getting Started is Simple! 

1๏ธโƒฃ Sign up / Log in at https://telebothost.com/ 

2๏ธโƒฃ Add your first bot โ€“ donโ€™t forget to read the guide

3๏ธโƒฃ Paste the codes and begin your adventure

Share your bot and codes with us to be part of our journey

๐Ÿค Donโ€™t forget to share this with your friends
Please open Telegram to view this post
VIEW IN TELEGRAM
โค2
Forwarded from Coding with Mohit
๐Ÿš€ Host Your Telegram Bot 24ร—7 for FREE (No VPS Needed!)

Still paying for VPS or struggling to keep your Telegram bot online?
Stop wasting money.

In this video, I show step-by-step how to host a Telegram bot completely FREE with 24ร—7 uptime.

โœ… Free hosting platform
โœ… Bot runs 24ร—7
โœ… No VPS, no server tension
โœ… Beginner-friendly


๐ŸŽฅ Watch now: https://www.youtube.com/results?search_query=Host+Telegram+Bot+24%2F7+for+FREE+%7C+No+VPS (Check thumbnail)

If youโ€™re serious about Telegram bot development, this one is non-negotiable.

โ€”
Join the community for more real, practical Telegram bot tutorials ๐Ÿ‘‡
๐Ÿ”— https://t.me/codingwithmohit05/4
โค3๐Ÿ‘1
Forwarded from xBotsBusiness
Our TBL Helper AI has crossed 300+ conversations ๐ŸŽ‰  on ChatGPT store

Try it and build your bots on telebothost.com -
https://chatgpt.com/g/g-690a0a4ffde4819193a77612b76d05e5-tbl-helper-ai

It is an AI assistant designed specially for:
โ€ข Telegram Bot Development 
โ€ข TeleBot Lang (TBL) 
โ€ข Automation & Bot Logic 
More updates, features & tools coming soon.

#Telegram #TelegramBots #ChatGPT #Programming #Developers
โค6
Forwarded from ๐Ÿค– Bjs Codes Flash (devendra)
โ” Code to get premium/custom emoji ids:

๐Ÿ“˜ Command: /emojiid
// /emojiid command handler
if (!params) {
Api.sendMessage({
text: "โ— <b>Usage</b>:\n<code>/emojiid &lt;message with premium emoji&gt;</code>",
parse_mode: "HTML"
});
return;
}

let text = "โŒ No premium/custom emojis found.";

// Check entities
if (request.entities && Array.isArray(request.entities)) {

let ids = [];

for (const entity of request.entities) {
if (
entity.type === "custom_emoji" &&
entity.custom_emoji_id
) {
ids.push(entity.custom_emoji_id);
}
}

if (ids.length > 0) {
text = "๐Ÿ†” <b>Premium Emoji IDs</b>:\n\n";

ids.forEach(id => {
text += `<tg-emoji emoji-id="${id}"></tg-emoji> <code>${id}</code>\n`;
});

text += "\n๐Ÿ“Œ <b>Usage</b>:\n";
text += "<b>HTML:</b>\n";
text += `<code>&lt;tg-emoji emoji-id="EMOJI_ID"&gt;&lt;/tg-emoji&gt;</code>\n\n`;

text += "<b>MarkdownV2:</b>\n";
text += `<code>![emoji](tg://emoji?id=EMOJI_ID)</code>`;
}
}

Api.sendMessage({
text: text,
parse_mode: "HTML"
});

๐Ÿง‘โ€๐Ÿ’ป Coded by @devendra
ยฉ๏ธ Copyright @BjsCodes
โค2
Custom emoji formatter

Automatically detects Telegram custom emojis in user messages and converts them into safe tg://emoji?id= references, wrapped in code format. Works with any text length and preserves original messages. Like @AdsMarkdownBot

Code :
/**
command: *
need_reply: false
*/

if (!msg || !msg.text) return;
if(chat.type != "private") return;

function escapeHTML(t) {
return t
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
}

let text = msg.text;
let entities = msg.entities || [];

let result = "";
let lastIndex = 0;
let hasCustomEmoji = false;

for (let i = 0; i < entities.length; i++) {
let e = entities[i];

if (e.type == "custom_emoji") {
hasCustomEmoji = true;
result += text.slice(lastIndex, e.offset);

let emojiChar = text.substr(e.offset, e.length);
result += "!["
+ emojiChar
+ "](tg://emoji?id="
+ e.custom_emoji_id
+ ")";

lastIndex = e.offset + e.length;
}
}

result += text.slice(lastIndex);

let out = hasCustomEmoji ? result : text;
out = escapeHTML(out);
out = "<code>" + out + "</code>";

let max = 3800;
for (let i = 0; i < out.length; i += max) {
Api.sendMessage({
chat_id: chat.id,
text: out.slice(i, i + max),
parse_mode: "HTML"
});
}


๐Ÿš€ Getting Started is Simple! 

1๏ธโƒฃ Sign up / Log in at https://telebothost.com/ 

2๏ธโƒฃ Add your first bot โ€“ donโ€™t forget to read the guide

3๏ธโƒฃ Paste the codes and begin your adventure

Share your bot and codes with us to be part of our journey

๐Ÿค Donโ€™t forget to share this with your friends
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿฅฐ1
// custom emoji ID
const EMOJI_ID = "5474667187258006816"

Api.sendMessage({
  text: "<b>๐Ÿ”ฅ New Button UI</b>\n\nInline + Keyboard colors & icons",
  parse_mode: "HTML",
  reply_markup: {
    inline_keyboard: [

      // Row 1
      [
        { text: "Normal", callback_data: "*" },
        { text: "Primary", callback_data: "*", style: "primary" }
      ],

      // Row 2
      [
        { text: "Success", callback_data: "*", style: "success" },
        { text: "Danger", callback_data: "*", style: "danger" }
      ],

      // Row 3 (Icon)
      [
        {
          text: "Icon Button",
          callback_data: "*",
          icon_custom_emoji_id: EMOJI_ID
        }
      ]
    ]
  }
})


// ---------- KEYBOARD ----------

Api.sendMessage({
  chat_id: chat.id,
  text: "โŒจ๏ธ Keyboard Button Test",
  reply_markup: {
    keyboard: [

      [
        { text: "Normal KB" },
        { text: "Primary KB", style: "primary" }
      ],

      [
        { text: "Success KB", style: "success" },
        { text: "Danger KB", style: "danger" }
      ],

      [
        {
          text: "Icon KB",
          icon_custom_emoji_id: EMOJI_ID
        }
      ]
    ],
    resize_keyboard: true
  }
})

Exclusive TBH (TBL) Code To Send Colored Button & Emoji Icon Button

By @Paradox0x0

Note: Custom icon only works if bot owner has telegram premium
โค8๐Ÿ‘3๐Ÿฅฐ3๐Ÿ˜2๐Ÿ”ฅ1
Forwarded from BIZ FACTORY (Mะบ Hฯƒั•ั•ฮฑฮนษณ)
๐Ÿง  Smart Telegram Auto Caption Bot for TeleBotHost (TBH)

Command: *

TBL Code:
function escapeHTML(text){
if(!text) return "";
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
}

let post = request;

if(!post || !post.message_id) return;
if(post.chat.type !== "channel") return;

let footer =
"\n\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n" +
"๐Ÿ“ข <b>Follow us for more updates!</b>\n" +
"๐Ÿ”— <a href='https://t.me/bizft'>Join our channel</a>";

let checkText = (post.caption || post.text || "");
if(checkText.includes("Join our channel")) return;

if(post.photo || post.video || post.document || post.audio){

let baseCaption = escapeHTML(post.caption ? post.caption.trim() : "");
let finalCaption = baseCaption ? (baseCaption + footer) : footer.trim();

if(finalCaption.length > 1024){
finalCaption = finalCaption.substring(0, 900) + "..." + footer;
}

Api.editMessageCaption({
chat_id: post.chat.id,
message_id: post.message_id,
caption: finalCaption,
parse_mode: "HTML"
});

return;
}

if(post.text){

let baseText = escapeHTML(post.text.trim());
let finalText = baseText + footer;

Api.editMessageText({
chat_id: post.chat.id,
message_id: post.message_id,
text: finalText,
parse_mode: "HTML",
disable_web_page_preview: true
});

return;
}


Setup Guide:
1๏ธโƒฃ Create Your Bot:
ยท Go to telebothost.com and create your bot

2๏ธโƒฃ Add Command:
ยท Create a new command * (wildcard)
ยท Paste the above code into the command

3๏ธโƒฃ Deploy & Test:
ยท Deploy your bot
ยท Send your chosen command to get a random quiz! โœ…

๐Ÿง Made BY @bizft
Please open Telegram to view this post
VIEW IN TELEGRAM
โค7๐Ÿคฌ3
let res = await HTTP.get(
"https://telebothost.com/logo.png",
{
headers: {
"x-response-type": "buffer"
}
}
);

const buffer = res.data;

Api.setChatPhoto({
//chat_id: "id" , //default is current chat
photo: buffer,
});

This is how you can set Profile photo of a group with TBL

And the same way you can use this trick on any method that need inputFile
๐Ÿ˜1
TBL Codes
๐Ÿ‘‹ Admin Contact Bot Codes For TeleBotHost command : @ TBL Code : let ADMINID = 5723455420; command : /start TBL Code : Api.sendMessage({ chat_id: chat.id, text: `๐Ÿ‘‹ Hello *${user.first_name}*! I'm here to help you connect with the *Admin*. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ€ฆ
//Use the all event Lister commnad * 

const ADMIN_ID = 5723455420;

function getOriginalUserIdByMessageId(messageId) {
let hiddenUserId = Bot.get("pvt" + messageId);
return hiddenUserId;
}

if(!msg) return;
if(chat.type != "private") return;
// to ensure that it's a message update and private chat

//forward any message from user to admin
if(chat.id != ADMIN_ID) {
let forwardResult = await Api.forwardMessage({
chat_id: ADMIN_ID,
from_chat_id: chat.id,
message_id: msg.message_id //msg is update.message
});

if(forwardResult?.result?.forward_origin?.type == "hidden_user") {
// Logic: When user has privacy mode enabled (hidden_user),
// store mapping between forwarded message ID and original user ID
// This allows admin to reply to hidden users by referencing the stored ID
Bot.set("pvt" + forwardResult?.result?.message_id, user.id);
}

msg.reply("*โœ… Message successfully sent to Admin*");
}

if(chat.id == ADMIN_ID && request?.reply_to_message) {

// if admin reply to forwarded message, send copy to user
let originalChatId = request.reply_to_message?.forward_from?.id ||
getOriginalUserIdByMessageId(request.reply_to_message.message_id);

Api.copyMessage({
chat_id: originalChatId,
from_chat_id: ADMIN_ID,
message_id: msg.message_id
});
}

Updated,

Added fallback logic to handle hidden_user (forward messages show disable)
โค4๐Ÿค”2
Forwarded from xBotsBusiness
Pinterest Image Search TBL Code
Api - https://pinterest-api-bay.vercel.app/example/docs

Command - /search
Wait for answer: On โœ…
TBL -
let query = message

if (!query) {
Bot.sendMessage("Please enter a search query.")
return
}

User.set("q", query, "string")

let res = await HTTP.post({
url: "https://pinterest-api-bay.vercel.app/v5/pins/search",
body: {
query: query,
count: 10,
compact: true
}
})

if (!res.ok) {
Bot.sendMessage("Request failed. Please try again later.")
return
}

let data

try {
data = res.data
} catch (e) {
Bot.sendMessage("Failed to parse response.")
return
}

if (!data.items || data.items.length === 0) {
Bot.sendMessage("No results found.")
return
}

let savedQuery = User.get("q") || "Result"
let botName = bot.name

for (let i = 0; i < data.items.length; i++) {
let item = data.items[i]

let title = item.title ? item.title : savedQuery
let image = item.image
let link = item.url ? item.url : ""

let buttons = []

if (link) {
buttons.push([{ text: "View on Pinterest", url: link }])
}

buttons.push([{ text: "Copy Image URL", copy_text: { text: image } }])

let caption =
"<b>" + title + "</b>\n" +
"<i>Query:</i> " + savedQuery + "\n" +
"<i>Searched by:</i> @" + botName

await Api.sendPhoto({
chat_id: user.telegramid,
photo: image,
caption: caption,
parse_mode: "HTML",
disable_web_page_preview: true,
reply_markup: {
inline_keyboard: buttons
}
})
}

Developer: @CyberXCoding
platform: telebothost.com
โค3๐Ÿ”ฅ3
Forwarded from ๐—ฃ๐—”๐—ฅ๐—”๐——๐—ข๐—ซ ๐Ÿ‡ฎ๐Ÿ‡ณ
/* Command: * */

if(!update.guest_message){ return }

let guest = update.guest_message
let text = (guest.text || "").toLowerCase()

let target = guest.from
let message = "@Durov"

// !info trigger
if(text.includes("!info")){

// replied user info
if(guest.reply_to_message){
let replied = guest.reply_to_message
if(replied.guest_bot_caller_user){
target = replied.guest_bot_caller_user
}else if(replied.from){
target = replied.from
}
}

let name = target.first_name || "โ€”"
let username = target.username
? "@" + target.username
: "โ€”"

let userid = target.id || "โ€”"

message =
`๐Ÿ‘ค ${name}
๐Ÿ†” ${userid}
๐Ÿ”— ${username}`
}

// guest reply
Api.call("answerGuestQuery", {
guest_query_id: guest.guest_query_id,
result: {
type: "article",
id: "reply",
title: "Reply",
description: "@Durov",
input_message_content: {
message_text: message
}
}
})

๐Ÿ”ฅ Tbl guest mode example code. Use query !info to get your or others info.
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ”ฅ3๐Ÿคฏ3โค1
Groq Ai TBL Code
Example of using Groq ai models in TBH


Command: *
TBL Code:
const GROQ_API_KEY =
"Api_Key"

const MODEL =
"llama-3.1-8b-instant"

const TOKEN = bot.token

async function editInline(id, text) {

return await HTTP.post({
url:
"https://api.telegram.org/bot" +
TOKEN +
"/editMessageText",

body: {
inline_message_id: id,
text: text
}
})

}

if (update.chosen_inline_result) {

try {

let query =
update.chosen_inline_result.query

let inlineMessageId =
update.chosen_inline_result.inline_message_id

if (!query || !inlineMessageId)
return

await editInline(
inlineMessageId,
"Thinking..."
)

let ai = await HTTP.post({

url:
"https://api.groq.com/openai/v1/chat/completions",

headers: {
Authorization:
"Bearer " +
GROQ_API_KEY
},

body: {
model: MODEL,

messages: [
{
role: "user",
content: query
}
]
}

})

let reply =
ai.data.choices[0].message.content

await editInline(
inlineMessageId,
reply || "No response"
)

} catch (e) {

await editInline(
update.chosen_inline_result
.inline_message_id,
"API Error"
)

}

}


Command: /inline_query
TBL Code:
try {

let query = request.query

if (!query || query.trim() === "") {

return await Api.answerInlineQuery({
inline_query_id: request.id,
results: [],
cache_time: 1
})

}

query = query.slice(0, 256)

await Api.answerInlineQuery({

inline_query_id: request.id,

cache_time: 1,

is_personal: true,

results: [
{
type: "article",

id: String(Date.now()),

title: "Ask AI",

description: query,

input_message_content: {
message_text: "Thinking... โ–Œ"
},

reply_markup: {
inline_keyboard: [
[
{
text: "โฌค",
callback_data: "loading"
}
]
]
}

}
]

})

} catch (e) {}


use groq/compound or groq/compound-mini ai model for real time info

Get a free api key from https://console.groq.com/keys
Example by: @CyberXCoding
โค4๐Ÿ‘2๐Ÿฅฐ1
Forwarded from xBotsBusiness
TBH Helper Ai was deleted on ChatGPT but don't worry we came with new TBH Helper Ai on Gemini -

Try it and build your bots on telebothost.com -
https://gemini.google.com/gem/1j_DmyTdxpxuBgtEJBOLVcCGumvVw5XmM?usp=sharing

TBH Helper Ai is a Expert:
โ€ข TeleBot Lang (TBL) 
โ€ข trained on TBH Docs docs.telebothost.com


More updates, features & tools coming soon.
it may do soe mistakes so give feedback so we can improve and do fixes
#Telegram #TelegramBots #ChatGPT #Programming #Developers
โค5
Forwarded from Soumyadeep โˆž
bot_1139149302.zip
2.8 KB
Official broadcast codes
โคโ€๐Ÿ”ฅ4๐Ÿ˜3
Forwarded from ๐—ฃ๐—”๐—ฅ๐—”๐——๐—ข๐—ซ ๐Ÿ‡ฎ๐Ÿ‡ณ
Demo TBH code for the new Bot API update ephemeral message.

Code:
/* Command: /ephemeral */

// Get target user and chat info
let targetUserId = user.id;
let groupId = chat.id;
let userName = user.first_name || "User";

// 1. Send Ephemeral Text Message
await Api.sendMessage({
chat_id: groupId,
text: "๐ŸŽฏ This message is only visible to you, " + userName + "!",
receiver_user_id: targetUserId,
parse_mode: "HTML"
});

// 2. Send Ephemeral Photo
await Api.sendPhoto({
chat_id: groupId,
photo: "https://telegram.org/img/t_logo.png",
caption: "๐Ÿ“ธ <b>Private Photo</b>\n\nOnly you can see this!",
receiver_user_id: targetUserId,
parse_mode: "HTML"
});

// 3. Send Ephemeral Sticker
await Api.sendSticker({
chat_id: groupId,
sticker: "CAACAgIAAxkBAAIxM2pbn6j6YZCWRUsSdh6sen7nBmJbAAL8HgACuNHQSheZ4BUjnIebPQQ",
receiver_user_id: targetUserId
});


For more explore new update!
โค2๐Ÿฅฐ2