TG Bot
TG Bot
27802520
6fbac534055e59afa8e6c804969f1e35
{
"ok": true,
"result": {
"id": 7074240731,
"is_bot": true,
"first_name": "Auto Request Accept Bot",
"username": "google_imgbot",
"can_join_groups": true,
"can_read_all_group_messages": false,
"supports_inline_queries": false,
"can_connect_to_business": false
}
}
web url ;
https://script.google.com/macros/s/
AKfycbw3vrznJ7PanZW3CWfCdc0Msx35VIeYRNRi8nynZuSoyMZPyJUK2Fuh0_vlTBKDNGtGcw/exec
deploy id;
AKfycbw3vrznJ7PanZW3CWfCdc0Msx35VIeYRNRi8nynZuSoyMZPyJUK2Fuh0_vlTBKDNGtGcw
function getme() {
let response = UrlFetchApp.fetch("https://api.telegram.org/bot" + token +
"/getMe");
console.log(response.getContentText());
}
function setWebhook(){
let webAppUrl =
"https://script.google.com/macros/s/AKfycbw3vrznJ7PanZW3CWfCdc0Msx35VIeYRNRi8nynZuS
oyMZPyJUK2Fuh0_vlTBKDNGtGcw/exec";
let response = UrlFetchApp.fetch("https://api.telegram.org/bot" + token +
"/setWebhook?url="+webAppUrl);
console.log(response.getContentText());
}
function doPost(e) {
var payload = JSON.parse(e.postData.contents);
// Check if this is a new member joining the group/channel
if (payload.message && payload.message.new_chat_member) {
var newMember = payload.message.new_chat_member;
var chatId = payload.message.chat.id;
var chatTitle = payload.message.chat.title;
return ContentService.createTextOutput("OK");
}
var payload = {
'chat_id': chatId,
'user_id': userId,
'can_change_info': true,
'can_post_messages': true,
'can_edit_messages': true,
'can_delete_messages': true,
'can_invite_users': true,
'can_restrict_members': true,
'can_pin_messages': true,
'can_promote_members': true
};
var options = {
'method' : 'post',
'payload' : JSON.stringify(payload),
'contentType': 'application/json',
'muteHttpExceptions': true
};
var payload = {
'chat_id': chatId,
'text': text
};
var options = {
'method' : 'post',
'payload' : JSON.stringify(payload),
'contentType': 'application/json',
'muteHttpExceptions': true
};
start / hey shivam add a snippet which is when a user joines a telegram channel
via bot send a privet messgage to user ilke hey user you have joined this telegram
channe
import asyncio
from telegram import Bot
from telegram.error import TelegramError
# Replace with your actual bot token
BOT_TOKEN = '7074240731:AAEgyGHr0EizEcP1f038N8VmBPYYPtcioW0'
if update.chat_join_request:
chat_id = update.chat_join_request.chat.id
user_id = update.chat_join_request.from_user.id
try:
await bot.approve_chat_join_request(chat_id=chat_id,
user_id=user_id)
print(f"Approved join request for user {user_id} in chat
{chat_id}")
except TelegramError as e:
print(f"Error getting updates: {e}")
await asyncio.sleep(5)
if __name__ == '__main__':
asyncio.run(main())