dhanilka commited on
Commit
51360e6
1 Parent(s): 0b9b99e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py CHANGED
@@ -2,6 +2,53 @@ import torch
2
  from PIL import Image
3
  from RealESRGAN import RealESRGAN
4
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
7
  model2 = RealESRGAN(device, scale=2)
 
2
  from PIL import Image
3
  from RealESRGAN import RealESRGAN
4
  import gradio as gr
5
+ import logging
6
+ from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
7
+ from telegram import Update
8
+
9
+
10
+ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
11
+ level=logging.INFO)
12
+
13
+ # Your API Token
14
+ TOKEN = "6231949511:AAH7-oU213cfrGYcfIMeaYOQUDf9kZoXc_0"
15
+
16
+ # Initialize the Updater
17
+ updater = Updater(token=TOKEN, use_context=True)
18
+ dispatcher = updater.dispatcher
19
+
20
+ # Define a command handler
21
+ def start(update: Update, context: CallbackContext):
22
+ context.bot.send_message(chat_id=update.effective_chat.id, text="Hello! I'm your bot. How can I help you?")
23
+
24
+ # Register the command handler
25
+ start_handler = CommandHandler('start', start)
26
+ dispatcher.add_handler(start_handler)
27
+
28
+ # Define a function to handle user messages
29
+ def echo(update: Update, context: CallbackContext):
30
+ context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text)
31
+
32
+ # Register the message handler
33
+ message_handler = MessageHandler(Filters.text & ~Filters.command, echo)
34
+ dispatcher.add_handler(message_handler)
35
+
36
+ # Start the bot
37
+ updater.start_polling()
38
+
39
+ # Run the bot until you send a signal to stop
40
+ updater.idle()
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
 
53
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
54
  model2 = RealESRGAN(device, scale=2)