mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 22:45:09 +01:00
Remove deprecated regexhandler from examples (#1426)
This commit is contained in:
parent
ac60d057a5
commit
3ae14dda80
3 changed files with 19 additions and 22 deletions
|
@ -21,7 +21,7 @@ bot.
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from telegram import (ReplyKeyboardMarkup, ReplyKeyboardRemove)
|
from telegram import (ReplyKeyboardMarkup, ReplyKeyboardRemove)
|
||||||
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
|
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
|
||||||
ConversationHandler)
|
ConversationHandler)
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
|
@ -131,7 +131,7 @@ def main():
|
||||||
entry_points=[CommandHandler('start', start)],
|
entry_points=[CommandHandler('start', start)],
|
||||||
|
|
||||||
states={
|
states={
|
||||||
GENDER: [RegexHandler('^(Boy|Girl|Other)$', gender)],
|
GENDER: [MessageHandler(Filters.regex('^(Boy|Girl|Other)$'), gender)],
|
||||||
|
|
||||||
PHOTO: [MessageHandler(Filters.photo, photo),
|
PHOTO: [MessageHandler(Filters.photo, photo),
|
||||||
CommandHandler('skip', skip_photo)],
|
CommandHandler('skip', skip_photo)],
|
||||||
|
|
|
@ -21,7 +21,7 @@ bot.
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from telegram import ReplyKeyboardMarkup
|
from telegram import ReplyKeyboardMarkup
|
||||||
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
|
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
|
||||||
ConversationHandler)
|
ConversationHandler)
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
|
@ -80,9 +80,9 @@ def received_information(update, context):
|
||||||
del user_data['choice']
|
del user_data['choice']
|
||||||
|
|
||||||
update.message.reply_text("Neat! Just so you know, this is what you already told me:"
|
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"
|
||||||
"You can tell me more, or change your opinion on something.".format(
|
" on something.".format(facts_to_str(user_data)),
|
||||||
facts_to_str(user_data)), reply_markup=markup)
|
reply_markup=markup)
|
||||||
|
|
||||||
return CHOOSING
|
return CHOOSING
|
||||||
|
|
||||||
|
@ -119,25 +119,22 @@ def main():
|
||||||
entry_points=[CommandHandler('start', start)],
|
entry_points=[CommandHandler('start', start)],
|
||||||
|
|
||||||
states={
|
states={
|
||||||
CHOOSING: [RegexHandler('^(Age|Favourite colour|Number of siblings)$',
|
CHOOSING: [MessageHandler(Filters.regex('^(Age|Favourite colour|Number of siblings)$'),
|
||||||
regular_choice,
|
regular_choice),
|
||||||
pass_user_data=True),
|
MessageHandler(Filters.regex('^Something else...$'),
|
||||||
RegexHandler('^Something else...$',
|
custom_choice)
|
||||||
custom_choice),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
TYPING_CHOICE: [MessageHandler(Filters.text,
|
TYPING_CHOICE: [MessageHandler(Filters.text,
|
||||||
regular_choice,
|
regular_choice)
|
||||||
pass_user_data=True),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
TYPING_REPLY: [MessageHandler(Filters.text,
|
TYPING_REPLY: [MessageHandler(Filters.text,
|
||||||
received_information,
|
received_information),
|
||||||
pass_user_data=True),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
fallbacks=[RegexHandler('^Done$', done, pass_user_data=True)]
|
fallbacks=[MessageHandler(Filters.regex('^Done$'), done)]
|
||||||
)
|
)
|
||||||
|
|
||||||
dp.add_handler(conv_handler)
|
dp.add_handler(conv_handler)
|
||||||
|
|
|
@ -19,7 +19,7 @@ bot.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from telegram import ReplyKeyboardMarkup
|
from telegram import ReplyKeyboardMarkup
|
||||||
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
|
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
|
||||||
ConversationHandler, PicklePersistence)
|
ConversationHandler, PicklePersistence)
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -129,10 +129,10 @@ def main():
|
||||||
entry_points=[CommandHandler('start', start)],
|
entry_points=[CommandHandler('start', start)],
|
||||||
|
|
||||||
states={
|
states={
|
||||||
CHOOSING: [RegexHandler('^(Age|Favourite colour|Number of siblings)$',
|
CHOOSING: [MessageHandler(Filters.regex('^(Age|Favourite colour|Number of siblings)$'),
|
||||||
regular_choice),
|
regular_choice),
|
||||||
RegexHandler('^Something else...$',
|
MessageHandler(Filters.regex('^Something else...$'),
|
||||||
custom_choice),
|
custom_choice),
|
||||||
],
|
],
|
||||||
|
|
||||||
TYPING_CHOICE: [MessageHandler(Filters.text,
|
TYPING_CHOICE: [MessageHandler(Filters.text,
|
||||||
|
@ -144,7 +144,7 @@ def main():
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
fallbacks=[RegexHandler('^Done$', done)],
|
fallbacks=[MessageHandler(Filters.regex('^Done$'), done)],
|
||||||
name="my_conversation",
|
name="my_conversation",
|
||||||
persistent=True
|
persistent=True
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue