Spaces:
Paused
Paused
File size: 1,983 Bytes
7b402a2 281a4a6 7b402a2 e137ea9 7b402a2 ff0cc88 7b402a2 ff0cc88 7b402a2 6bd693f 7b402a2 6bd693f 7b402a2 6bd693f 7b402a2 6bd693f 7b402a2 6bd693f 6b4864f e137ea9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import gradio as gr
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext, CallbackQueryHandler
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('Welcome Sir.')
def handle_message(update: Update, context: CallbackContext) -> None:
user = update.message.from_user
if user.username == 'Mohammed_Alakhras':
if update.message.document:
context.bot.send_document(chat_id=update.message.chat_id,
document=update.message.document.file_id,
caption='معاينة',
thumb='a.png')
else:
update.message.reply_text('Only The Admin Can Use this Bot./n@Mohammed_Alakhras')
context.bot.forward_message(chat_id='@Mohammed_Alakhras',
from_chat_id=update.message.chat_id,
message_id=update.message.message_id)
def handle_callback(update: Update, context: CallbackContext) -> None:
query = update.callback_query
query.answer()
query.edit_message_text(text=f"Selected option: {query.data}")
def main() -> None:
updater = Updater("5782912329:AAEIcqsSUpuLxYtIk8RMsZgDYviUlQZ3zso", use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, handle_message))
dispatcher.add_handler(CallbackQueryHandler(handle_callback))
updater.start_polling()
updater.idle()
def run_bot():
main()
inputs = []
output = "text"
gr.Interface(fn=main, inputs=inputs, outputs=run_bot).launch()
|