3535def start (bot , update ):
3636 reply_keyboard = [['Boy' , 'Girl' , 'Other' ]]
3737
38- bot . sendMessage ( update .message .chat_id ,
39- text = 'Hi! My name is Professor Bot. I will hold a conversation with you. '
40- 'Send /cancel to stop talking to me.\n \n '
41- 'Are you a boy or a girl?' ,
42- reply_markup = ReplyKeyboardMarkup (reply_keyboard , one_time_keyboard = True ))
38+ update .message .reply_text (
39+ 'Hi! My name is Professor Bot. I will hold a conversation with you. '
40+ 'Send /cancel to stop talking to me.\n \n '
41+ 'Are you a boy or a girl?' ,
42+ reply_markup = ReplyKeyboardMarkup (reply_keyboard , one_time_keyboard = True ))
4343
4444 return GENDER
4545
4646
4747def gender (bot , update ):
4848 user = update .message .from_user
4949 logger .info ("Gender of %s: %s" % (user .first_name , update .message .text ))
50- bot .sendMessage (update .message .chat_id ,
51- text = 'I see! Please send me a photo of yourself, '
52- 'so I know what you look like, or send /skip if you don\' t want to.' )
50+ update .message .reply_text ('I see! Please send me a photo of yourself, '
51+ 'so I know what you look like, or send /skip if you don\' t want to.' )
5352
5453 return PHOTO
5554
@@ -59,17 +58,17 @@ def photo(bot, update):
5958 photo_file = bot .getFile (update .message .photo [- 1 ].file_id )
6059 photo_file .download ('user_photo.jpg' )
6160 logger .info ("Photo of %s: %s" % (user .first_name , 'user_photo.jpg' ))
62- bot . sendMessage ( update .message .chat_id , text = 'Gorgeous! Now, send me your location please, '
63- 'or send /skip if you don\' t want to.' )
61+ update .message .reply_text ( 'Gorgeous! Now, send me your location please, '
62+ 'or send /skip if you don\' t want to.' )
6463
6564 return LOCATION
6665
6766
6867def skip_photo (bot , update ):
6968 user = update .message .from_user
7069 logger .info ("User %s did not send a photo." % user .first_name )
71- bot . sendMessage ( update .message .chat_id , text = 'I bet you look great! Now, send me your '
72- 'location please, or send /skip.' )
70+ update .message .reply_text ( 'I bet you look great! Now, send me your location please, '
71+ ' or send /skip.' )
7372
7473 return LOCATION
7574
@@ -79,35 +78,33 @@ def location(bot, update):
7978 user_location = update .message .location
8079 logger .info ("Location of %s: %f / %f"
8180 % (user .first_name , user_location .latitude , user_location .longitude ))
82- bot . sendMessage ( update .message .chat_id , text = 'Maybe I can visit you sometime! '
83- 'At last, tell me something about yourself.' )
81+ update .message .reply_text ( 'Maybe I can visit you sometime! '
82+ 'At last, tell me something about yourself.' )
8483
8584 return BIO
8685
8786
8887def skip_location (bot , update ):
8988 user = update .message .from_user
9089 logger .info ("User %s did not send a location." % user .first_name )
91- bot . sendMessage ( update .message .chat_id , text = 'You seem a bit paranoid! '
92- 'At last, tell me something about yourself.' )
90+ update .message .reply_text ( 'You seem a bit paranoid! '
91+ 'At last, tell me something about yourself.' )
9392
9493 return BIO
9594
9695
9796def bio (bot , update ):
9897 user = update .message .from_user
9998 logger .info ("Bio of %s: %s" % (user .first_name , update .message .text ))
100- bot .sendMessage (update .message .chat_id ,
101- text = 'Thank you! I hope we can talk again some day.' )
99+ update .message .reply_text ('Thank you! I hope we can talk again some day.' )
102100
103101 return ConversationHandler .END
104102
105103
106104def cancel (bot , update ):
107105 user = update .message .from_user
108106 logger .info ("User %s canceled the conversation." % user .first_name )
109- bot .sendMessage (update .message .chat_id ,
110- text = 'Bye! I hope we can talk again some day.' )
107+ update .message .reply_text ('Bye! I hope we can talk again some day.' )
111108
112109 return ConversationHandler .END
113110
0 commit comments