-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.py
105 lines (102 loc) · 3.26 KB
/
handlers.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
import functions
from telegram.ext import (
CommandHandler,
ConversationHandler,
MessageHandler,
filters,
)
# States for the bot
TYPING_BARCODE, CHOOSING, TYPING_PAPER, TYPING_ISSUE, CHOOSING_CLASS, CHOOSING_OPERATION, CHOOSING_ANALYTIC, CHOOSING_CLASS_ANALYTIC = range(
8)
conv_handler = ConversationHandler(
entry_points=[CommandHandler("start", functions.start)],
states={
CHOOSING: [
MessageHandler(
filters.Regex("^🧾 Get Papers$"), functions.choose_class
),
MessageHandler(
filters.Regex("^📍 Paper Issues$"), functions.paper_issue
),
MessageHandler(
filters.Regex("^📊 See Analysis$"), functions.get_analytics
),
MessageHandler(
filters.Regex("^❌ Close"), functions.done
),
MessageHandler(
filters.TEXT, functions.invalid_choice_1
),
],
TYPING_BARCODE: [
MessageHandler(
filters.Regex("^[0-9]{8,10}$"), functions.enter_barcode
),
CommandHandler("close", functions.done),
MessageHandler(
filters.TEXT, functions.invalid_input_1
)
],
TYPING_PAPER: [
MessageHandler(
filters.Regex("^[0-9]*$"), functions.enter_paper_no
),
CommandHandler("close", functions.done),
MessageHandler(
filters.TEXT, functions.invalid_input_2
)
],
TYPING_ISSUE: [
MessageHandler(
filters.Regex("^❌ Cancel$"), functions.cancel_issue
),
MessageHandler(
filters.TEXT, functions.enter_paper_issue
)
],
CHOOSING_CLASS: [
CommandHandler("close", functions.done),
MessageHandler(
filters.TEXT, functions.choose_operation
)
],
CHOOSING_OPERATION: [
MessageHandler(
filters.Regex("^🔖 Get Marks$"), functions.get_marks
),
MessageHandler(
filters.Regex(
"^📝 Get Marked Paper$"), functions.get_papers
),
MessageHandler(
filters.Regex("^❌ Close"), functions.done
),
MessageHandler(
filters.TEXT, functions.invalid_choice_2
),
],
CHOOSING_ANALYTIC: [
MessageHandler(
filters.Regex(
"^📊 Get Data Analysis$"), functions.get_data_analytics
),
MessageHandler(
filters.Regex(
"^📈 Get Graph Analysis$"), functions.get_graph_analytics
),
MessageHandler(
filters.Regex("^❌ Close"), functions.done
),
MessageHandler(
filters.TEXT, functions.invalid_choice_3
),
],
CHOOSING_CLASS_ANALYTIC: [
MessageHandler(
filters.TEXT, functions.showAnalytics
),
]
},
fallbacks=[
MessageHandler(filters.Regex("^❌ Close"), functions.done)],
)