-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
129 lines (116 loc) · 4.22 KB
/
main.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import logging
from Classes import *
from Components import *
from telegram.ext import *
from telegram import *
config = ConfigManager("dev.config")
api_key = config.get("telegram_key")
home = Home()
profile = Profile()
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
def main() -> None:
"""Run the bot."""
# Create the Application and pass it your bot's token.
application = ApplicationBuilder().token(api_key).build()
profile_handler = ConversationHandler(
entry_points=[CallbackQueryHandler(callback=profile.profile_home,
pattern="profile"),
CallbackQueryHandler(callback=profile.new_user_age,
pattern="new_profile")
],
states={
"PROFILE_HOME": [
CallbackQueryHandler(
callback=profile.edit_your_age,
pattern="personal_info"
),
CallbackQueryHandler(
callback=profile.edit_your_cuisine_pref,
pattern="food_pref"
),
CallbackQueryHandler(
callback=profile.choose_buddy_age_pref,
pattern="buddy_pref"
),
],
"NEW_CHOOSING_AGE": [
CallbackQueryHandler(
callback=profile.handle_new_user_age__new_user_gender,
pattern="1|2|3|4|5|6"
)
],
"NEW_CHOOSING_GENDER": [
CallbackQueryHandler(
callback=profile.handle_new_user_gender__home,
pattern="1|2|3"
)
],
"CHOOSING_AGE": [
CallbackQueryHandler(
callback=profile.handle_choosing_age__edit_gender,
pattern="1|2|3|4|5|6"
)
],
"CHOOSING_GENDER": [
CallbackQueryHandler(
callback=profile.handle_choosing_gender__home,
pattern="1|2|3"
)
],
"CHOOSING_CUISINE": [
CallbackQueryHandler(
callback=profile.handle_choosing_cuisine__edit_diet,
pattern="1|2|3|4|5|6|7|8|Select All|Done"
)
],
"CHOOSING_DIET": [
CallbackQueryHandler(
callback=profile.handle_choosing_diet__home,
pattern="1|2|3|Select All|Done"
)
],
"CHOOSING_BUDDY_AGE": [
CallbackQueryHandler(
callback=profile.handle_buddy_age__buddy_gender,
pattern="1|2|3|4|5|6|Select All|Done"
)
],
"CHOOSING_BUDDY_GENDER": [
CallbackQueryHandler(
callback=profile.handle_buddy_gender__home,
pattern="1|2|3|Select All|Done"
)
]
},
fallbacks=[CommandHandler("start", home.start)],
name="profile_conversation",
persistent=False,
allow_reentry=True
)
# Add conversation handler with the states CHOOSING, TYPING_CHOICE and TYPING_REPLY
home_handler = ConversationHandler(
entry_points=[CommandHandler("start", home.start),
CallbackQueryHandler(callback=home.back_to_start,
pattern="home")],
states={
"HOME_START": [
CallbackQueryHandler(
callback=home.not_implemented_yet,
pattern="match"
)
],
},
fallbacks=[MessageHandler(filters.Regex("^Done$"), home.start)],
name="home_conversation",
persistent=False,
allow_reentry=True
)
application.add_handler(home_handler)
application.add_handler(profile_handler)
# Run the bot until the user presses Ctrl-C
application.run_polling()
if __name__ == '__main__':
main()