88from telegram import Emoji , ForceReply , ReplyKeyboardMarkup , KeyboardButton
99from telegram .ext import Updater , CommandHandler , MessageHandler , Filters
1010
11- logging .basicConfig (format = '%(asctime)s - %(name)s - %(levelname)s - '
12- '%(message)s' ,
11+ logging .basicConfig (format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' ,
1312 level = logging .INFO )
1413
1514# Define the different states a chat can be in
1615MENU , AWAIT_CONFIRMATION , AWAIT_INPUT = range (3 )
1716
1817# Python 2 and 3 unicode differences
1918try :
20- YES , NO = (Emoji .THUMBS_UP_SIGN .decode ('utf-8' ),
21- Emoji .THUMBS_DOWN_SIGN .decode ('utf-8' ))
19+ YES , NO = (Emoji .THUMBS_UP_SIGN .decode ('utf-8' ), Emoji .THUMBS_DOWN_SIGN .decode ('utf-8' ))
2220except AttributeError :
2321 YES , NO = (Emoji .THUMBS_UP_SIGN , Emoji .THUMBS_DOWN_SIGN )
2422
@@ -46,7 +44,7 @@ def set_value(bot, update):
4644 context [chat_id ] = user_id # save the user id to context
4745 bot .sendMessage (chat_id ,
4846 text = "Please enter your settings value or send "
49- "/cancel to abort" ,
47+ "/cancel to abort" ,
5048 reply_markup = ForceReply ())
5149
5250 # If we are waiting for input and the right user answered
@@ -58,21 +56,18 @@ def set_value(bot, update):
5856 reply_markup = ReplyKeyboardMarkup (
5957 [[KeyboardButton (YES ), KeyboardButton (NO )]],
6058 one_time_keyboard = True )
61- bot .sendMessage (chat_id , text = "Are you sure?" ,
62- reply_markup = reply_markup )
59+ bot .sendMessage (chat_id , text = "Are you sure?" , reply_markup = reply_markup )
6360
6461 # If we are waiting for confirmation and the right user answered
6562 elif chat_state == AWAIT_CONFIRMATION and chat_context [0 ] == user_id :
6663 del state [chat_id ]
6764 del context [chat_id ]
6865 if text == YES :
6966 values [chat_id ] = chat_context [1 ]
70- bot .sendMessage (chat_id ,
71- text = "Changed value to %s." % values [chat_id ])
67+ bot .sendMessage (chat_id , text = "Changed value to %s." % values [chat_id ])
7268 else :
7369 bot .sendMessage (chat_id ,
74- text = "Value not changed: %s."
75- % values .get (chat_id , '<not set>' ))
70+ text = "Value not changed: %s." % values .get (chat_id , '<not set>' ))
7671
7772
7873# Handler for the /cancel command.
@@ -86,7 +81,6 @@ def cancel(bot, update):
8681def help (bot , update ):
8782 bot .sendMessage (update .message .chat_id , text = "Use /set to test this bot." )
8883
89-
9084# Create the Updater and pass it your bot's token.
9185updater = Updater ("TOKEN" )
9286
0 commit comments