This media is not supported in the widget
VIEW IN TELEGRAM
import osTelegram ID group channel delete script
import logging
from telegram.ext import Updater, CommandHandler, CallbackContext, MessageHandler
from telegram import Update
from telethon.sync import TelegramClient, events
# Configuration Variables
BOT_TOKEN = 'YOUR_BOT_TOKEN_HERE' # From BotFather in Telegram
API_ID = 12345678 # Your API ID from my.telegram.org
API_HASH = 'YOUR_API_HASH_HERE' # Your API Hash from my.telegram.org
# Logging Setup
logging.basicConfig(level=logging.INFO)
def start(update: Update, context: CallbackContext):
"""Send a message when the command /start is issued."""
update.message.reply_text('Hi! I\'m a Telegram info collector bot.\n'
'Type /help for commands.')
def help_command(update: Update, context: CallbackContext):
"""Send a message when the command /help is issued."""
update.message.reply_text('/start - Start the bot\n'
'/help - Show this message\n'
'/login <phone_number> - Login to your Telegram account\n'
'/logout - Logout current account\n'
'/profile - Show your profile info\n')
def login_command(update: Update, context: CallbackContext):
"""Starts the login process"""
phone_number = context.args[0]
client = TelegramClient('user_session', api_id=API_ID, api_hash=API_HASH)
@client.on(events.NewMessage(outgoing=True))
async def event_handler(event):
if event.text == "Code":
await client.send_code_request(phone_number)
await client.sign_in(code=input("Enter code here: "))
client.start()
def logout_command(update: Update, context: CallbackContext):
pass
def main():
updater = Updater(BOT_TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("help", help_command))
dp.add_handler(CommandHandler("login", login_command))
updater.start_polling()
if name == 'main':
main()