-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (32 loc) · 902 Bytes
/
Copy pathmain.py
File metadata and controls
46 lines (32 loc) · 902 Bytes
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
from telegram import Bot, Update
from telegram.ext import Updater, MessageHandler, Filters
TG_TOKEN = 'ччч'
def message_handler(bot: Bot, update: Update):
user = update.effective_user
if user:
name = user.first_name
else:
name = 'anonymous'
text = update.effective_message.text
reply_text = f'Привет, {name}!\n\n{text}'
bot.send_message(
chat_id = update.effective_message.chat_id,
text = reply_text,
)
return
def main():
print('start')
bot = Bot(
token = TG_TOKEN,
base_url="https://telegg.ru/orig/bot",
)
updater = Updater(
bot = bot,
)
handler = MessageHandler(Filters.all, message_handler)
updater.dispatcher.add_handler(handler)
updater.start_polling()
updater.idle()
print('finish')
if __name__ == '__main__':
main()