5
5
6
6
from emoji import emojize
7
7
from telegram import InlineKeyboardButton , InlineKeyboardMarkup , Update
8
- from telegram .error import BadRequest
9
8
from telegram .ext import (CallbackContext , CallbackQueryHandler ,
10
9
CommandHandler , PicklePersistence , Updater )
11
10
@@ -24,7 +23,7 @@ def start(update: Update, context: CallbackContext) -> None:
24
23
'\n Выберете место кнопками ниже' )
25
24
update .effective_message .reply_text (welcome , parse_mode = 'MarkdownV2' )
26
25
update .effective_message .reply_text (
27
- parking .state_text , reply_markup = markup , parse_mode = 'MarkdownV2' )
26
+ parking .state_text , reply_markup = markup )
28
27
log_event (update , 'Отправил start' )
29
28
30
29
@@ -47,7 +46,6 @@ def parking_handler(update: Update, context: CallbackContext) -> None:
47
46
if (config ['whitelist' ] and str (update .effective_user .id ) in users
48
47
or not config ['whitelist' ]):
49
48
manage_user (update , context )
50
- context .user_data ['is_in_menu' ] = False
51
49
number = update .callback_query .data
52
50
try :
53
51
parking = context .bot_data ['parking' ]
@@ -78,7 +76,6 @@ def cancel_handler(update: Update, context: CallbackContext) -> None:
78
76
if (config ['whitelist' ] and str (update .effective_user .id ) in users
79
77
or not config ['whitelist' ]):
80
78
manage_user (update , context )
81
- context .user_data ['is_in_menu' ] = False
82
79
number = update .callback_query .data .split ('.' )[1 ]
83
80
parking = context .bot_data ['parking' ]
84
81
try :
@@ -101,7 +98,6 @@ def clear_handler(update: Update, context: CallbackContext) -> None:
101
98
if (config ['whitelist' ] and str (update .effective_user .id ) in users
102
99
or not config ['whitelist' ]):
103
100
manage_user (update , context )
104
- context .user_data ['is_in_menu' ] = False
105
101
try :
106
102
parking = context .bot_data ['parking' ]
107
103
places = parking .clear ()
@@ -121,7 +117,7 @@ def clear_handler(update: Update, context: CallbackContext) -> None:
121
117
122
118
123
119
def statistics_handler (update : Update , context : CallbackContext ) -> None :
124
- """Handler for statistic menu button."""
120
+ """Handler for statistic button."""
125
121
if (config ['whitelist' ] and str (update .effective_user .id ) in users
126
122
or not config ['whitelist' ]):
127
123
manage_user (update , context )
@@ -133,7 +129,7 @@ def statistics_handler(update: Update, context: CallbackContext) -> None:
133
129
134
130
def update_state (update : Update , context : CallbackContext , info : str ,
135
131
personal = False ) -> None :
136
- """Sends personal or bulk messages by updating .
132
+ """Sends personal or bulk messages to users .
137
133
138
134
Args:
139
135
update: for identifying users and getting bot for bulk send.
@@ -145,10 +141,9 @@ def update_state(update: Update, context: CallbackContext, info: str,
145
141
parking = context .bot_data ['parking' ]
146
142
if personal :
147
143
markup = make_keyboard (context , str (update .effective_user .id ))
148
- update .effective_message .reply_text (
149
- text = info , parse_mode = 'MarkdownV2' )
150
- update .effective_message .reply_text (
151
- text = parking .state_text , reply_markup = markup )
144
+ update .effective_message .reply_text (info , parse_mode = 'MarkdownV2' )
145
+ update .effective_message .reply_text (parking .state_text ,
146
+ reply_markup = markup )
152
147
else :
153
148
for user in users :
154
149
markup = make_keyboard (context , user )
@@ -317,8 +312,8 @@ def get_logs(update: Update, context: CallbackContext) -> None:
317
312
318
313
def main ():
319
314
updater = Updater (token = config ['token' ], persistence = PicklePersistence (
320
- filename = config ['data_file_prefix ' ], store_chat_data = False ,
321
- single_file = False , on_flush = False ))
315
+ filename = config ['data_file ' ], store_chat_data = False ,
316
+ store_user_data = False , on_flush = False ))
322
317
dispatcher = updater .dispatcher
323
318
dispatcher .bot_data ['stats' ] = dispatcher .bot_data .get ('stats' ,
324
319
Stats (users ))
0 commit comments