-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
77 lines (64 loc) · 1.78 KB
/
bot.py
File metadata and controls
77 lines (64 loc) · 1.78 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from dotenv import load_dotenv
load_dotenv()
import common.sentry
from common.settings import Settings
from common.dictionary import dictionary
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
Filters,
PreCheckoutQueryHandler,
InlineQueryHandler,
)
from handlers import (
start,
products,
terms,
successful_payment,
pre_checkout,
inline_query,
)
def main() -> None:
settings = Settings()
updater = Updater(settings.bot_token)
dispatcher = updater.dispatcher
# Simple start function
dispatcher.add_handler(CommandHandler("start", start.start))
# Products handler
dispatcher.add_handler(
MessageHandler(
Filters.regex(f'^{dictionary["en"].products}$'), products.products_handler
)
)
dispatcher.add_handler(
MessageHandler(
Filters.regex(f'^{dictionary["ru"].products}$'), products.products_handler
)
)
# Terms & Conditions handler
dispatcher.add_handler(
MessageHandler(
Filters.regex(f'^{dictionary["ru"].terms_and_conditions}$'), terms.terms
)
)
dispatcher.add_handler(
MessageHandler(
Filters.regex(f'^{dictionary["en"].terms_and_conditions}$'), terms.terms
)
)
# Inline query handler
dispatcher.add_handler(InlineQueryHandler(inline_query.inline_query))
# Pre-checkout handler to final check
dispatcher.add_handler(PreCheckoutQueryHandler(pre_checkout.pre_checkout))
# Success! Notify your user!
dispatcher.add_handler(
MessageHandler(
Filters.successful_payment, successful_payment.successful_payment
)
)
# Start the Bot
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()