DmitrMakeev commited on
Commit
0b73a55
·
verified ·
1 Parent(s): aae04c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -99,20 +99,36 @@ TOKEN = "7766407698:AAGZHEbUuiOri4_YzZ7hDPSD6U8MGMXXSnA"
99
  # Инициализация Teleflask
100
  app = Teleflask(TOKEN)
101
 
102
- # Обработчик команды /start
103
- @app.message_handler(commands=["start"])
104
- def start(update):
105
- return SendMessage(update.chat.id, "Привет! Я бот на Teleflask.")
106
-
107
- # Обработчик команды /help
108
- @app.message_handler(commands=["help"])
109
- def help_command(update):
110
- return SendMessage(update.chat.id, "Доступные команды: /start, /help")
111
-
112
- # Обработчик всех текстовых сообщений
113
- @app.message_handler()
114
- def echo(update):
115
- return SendMessage(update.chat.id, f"Ты сказал: {update.text}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
 
118
 
 
99
  # Инициализация Teleflask
100
  app = Teleflask(TOKEN)
101
 
102
+ @app.route("/")
103
+ def index():
104
+ return "This is a normal Flask page."
105
+ # end def
106
+
107
+
108
+ # Register the /start command
109
+ @bot.command("start")
110
+ def start(update, text):
111
+ # update is the update object. It is of type pytgbot.api_types.receivable.updates.Update
112
+ # text is the text after the command. Can be empty. Type is str.
113
+ return TextMessage("<b>Hello!</b> Thanks for using @" + bot.username + "!", parse_mode="html")
114
+ # end def
115
+
116
+
117
+ # register a function to be called for updates.
118
+ @bot.on_update
119
+ def foo(update):
120
+ from pytgbot.api_types.receivable.updates import Update
121
+ assert isinstance(update, Update)
122
+ # do stuff with the update
123
+ # you can use bot.bot to access the pytgbot.Bot's messages functions
124
+ if not update.message:
125
+ return
126
+ # you could use @bot.on_message instead of this if.
127
+ # end if
128
+ if update.message.new_chat_member:
129
+ return TextMessage("Welcome!")
130
+ # end if
131
+ # end def
132
 
133
 
134