Remove deprecated regexhandler from examples (#1426)

This commit is contained in:
Eldinnie 2019-08-23 21:32:12 +02:00 committed by Noam Meltzer
parent ac60d057a5
commit 3ae14dda80
3 changed files with 19 additions and 22 deletions

View file

@ -21,7 +21,7 @@ bot.
import logging
from telegram import (ReplyKeyboardMarkup, ReplyKeyboardRemove)
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
ConversationHandler)
# Enable logging
@ -131,7 +131,7 @@ def main():
entry_points=[CommandHandler('start', start)],
states={
GENDER: [RegexHandler('^(Boy|Girl|Other)$', gender)],
GENDER: [MessageHandler(Filters.regex('^(Boy|Girl|Other)$'), gender)],
PHOTO: [MessageHandler(Filters.photo, photo),
CommandHandler('skip', skip_photo)],

View file

@ -21,7 +21,7 @@ bot.
import logging
from telegram import ReplyKeyboardMarkup
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
ConversationHandler)
# Enable logging
@ -80,9 +80,9 @@ def received_information(update, context):
del user_data['choice']
update.message.reply_text("Neat! Just so you know, this is what you already told me:"
"{}"
"You can tell me more, or change your opinion on something.".format(
facts_to_str(user_data)), reply_markup=markup)
"{} You can tell me more, or change your opinion"
" on something.".format(facts_to_str(user_data)),
reply_markup=markup)
return CHOOSING
@ -119,25 +119,22 @@ def main():
entry_points=[CommandHandler('start', start)],
states={
CHOOSING: [RegexHandler('^(Age|Favourite colour|Number of siblings)$',
regular_choice,
pass_user_data=True),
RegexHandler('^Something else...$',
custom_choice),
CHOOSING: [MessageHandler(Filters.regex('^(Age|Favourite colour|Number of siblings)$'),
regular_choice),
MessageHandler(Filters.regex('^Something else...$'),
custom_choice)
],
TYPING_CHOICE: [MessageHandler(Filters.text,
regular_choice,
pass_user_data=True),
regular_choice)
],
TYPING_REPLY: [MessageHandler(Filters.text,
received_information,
pass_user_data=True),
received_information),
],
},
fallbacks=[RegexHandler('^Done$', done, pass_user_data=True)]
fallbacks=[MessageHandler(Filters.regex('^Done$'), done)]
)
dp.add_handler(conv_handler)

View file

@ -19,7 +19,7 @@ bot.
"""
from telegram import ReplyKeyboardMarkup
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
ConversationHandler, PicklePersistence)
import logging
@ -129,10 +129,10 @@ def main():
entry_points=[CommandHandler('start', start)],
states={
CHOOSING: [RegexHandler('^(Age|Favourite colour|Number of siblings)$',
regular_choice),
RegexHandler('^Something else...$',
custom_choice),
CHOOSING: [MessageHandler(Filters.regex('^(Age|Favourite colour|Number of siblings)$'),
regular_choice),
MessageHandler(Filters.regex('^Something else...$'),
custom_choice),
],
TYPING_CHOICE: [MessageHandler(Filters.text,
@ -144,7 +144,7 @@ def main():
],
},
fallbacks=[RegexHandler('^Done$', done)],
fallbacks=[MessageHandler(Filters.regex('^Done$'), done)],
name="my_conversation",
persistent=True
)