-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull.py
More file actions
51 lines (38 loc) · 1.6 KB
/
full.py
File metadata and controls
51 lines (38 loc) · 1.6 KB
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
from telegram_chatbot_python import GreenAPIBot, Notification
bot = GreenAPIBot(
"4100000000", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)
@bot.router.message(command="start")
def message_handler(notification: Notification) -> None:
sender_data = notification.event["senderData"]
sender_name = sender_data["senderName"]
notification.answer(
(
f"Hello, {sender_name}. Here's what I can do:\n\n"
"1. Report a problem\n"
"2. Show office address\n"
"3. Show available rates\n"
"4. Call a support operator\n"
"Choose a number and send to me."
)
)
@bot.router.message(text_message=["1", "Report a problem"])
def report_problem_handler(notification: Notification) -> None:
notification.answer(
"https://github.com/green-api/issues/issues/new", link_preview=False, typing_time=2000
)
@bot.router.message(text_message=["2", "Show office address"])
def show_office_address_handler(notification: Notification) -> None:
chat = notification.chat
notification.api.sending.sendLocation(
chatId=chat, latitude=55.7522200, longitude=37.6155600
)
@bot.router.message(text_message=["3", "Show available rates"])
def show_available_rates_handler(notification: Notification) -> None:
notification.answer_with_file("examples/data/rates.png")
@bot.router.message(text_message=["4", "Call a support operator"])
def call_support_operator_handler(notification: Notification) -> None:
notification.answer(
"Good. A tech support operator will contact you soon."
)
bot.run_forever()