99from telegram .ext import Updater , CommandHandler , MessageHandler , Filters
1010
1111logging .basicConfig (format = '%(asctime)s - %(name)s - %(levelname)s - '
12- '%(message)s' ,
12+ '%(message)s' ,
1313 level = logging .INFO )
1414
1515# Define the different states a chat can be in
1616MENU , AWAIT_CONFIRMATION , AWAIT_INPUT = range (3 )
1717
1818# Python 2 and 3 unicode differences
1919try :
20- YES , NO = (Emoji .THUMBS_UP_SIGN .decode ('utf-8' ),
21- Emoji .THUMBS_DOWN_SIGN .decode ('utf-8' ))
20+ YES , NO = (Emoji .THUMBS_UP_SIGN .decode ('utf-8' ), Emoji .THUMBS_DOWN_SIGN .decode ('utf-8' ))
2221except AttributeError :
2322 YES , NO = (Emoji .THUMBS_UP_SIGN , Emoji .THUMBS_DOWN_SIGN )
2423
@@ -46,7 +45,7 @@ def set_value(bot, update):
4645 context [chat_id ] = user_id # save the user id to context
4746 bot .sendMessage (chat_id ,
4847 text = "Please enter your settings value or send "
49- "/cancel to abort" ,
48+ "/cancel to abort" ,
5049 reply_markup = ForceReply ())
5150
5251 # If we are waiting for input and the right user answered
@@ -58,21 +57,18 @@ def set_value(bot, update):
5857 reply_markup = ReplyKeyboardMarkup (
5958 [[KeyboardButton (YES ), KeyboardButton (NO )]],
6059 one_time_keyboard = True )
61- bot .sendMessage (chat_id , text = "Are you sure?" ,
62- reply_markup = reply_markup )
60+ bot .sendMessage (chat_id , text = "Are you sure?" , reply_markup = reply_markup )
6361
6462 # If we are waiting for confirmation and the right user answered
6563 elif chat_state == AWAIT_CONFIRMATION and chat_context [0 ] == user_id :
6664 del state [chat_id ]
6765 del context [chat_id ]
6866 if text == YES :
6967 values [chat_id ] = chat_context [1 ]
70- bot .sendMessage (chat_id ,
71- text = "Changed value to %s." % values [chat_id ])
68+ bot .sendMessage (chat_id , text = "Changed value to %s." % values [chat_id ])
7269 else :
7370 bot .sendMessage (chat_id ,
74- text = "Value not changed: %s."
75- % values .get (chat_id , '<not set>' ))
71+ text = "Value not changed: %s." % values .get (chat_id , '<not set>' ))
7672
7773
7874# Handler for the /cancel command.
@@ -86,7 +82,6 @@ def cancel(bot, update):
8682def help (bot , update ):
8783 bot .sendMessage (update .message .chat_id , text = "Use /set to test this bot." )
8884
89-
9085# Create the Updater and pass it your bot's token.
9186updater = Updater ("TOKEN" )
9287
0 commit comments