Skip to content

Commit

Permalink
Add character filter
Browse files Browse the repository at this point in the history
  • Loading branch information
HexRabbit committed Aug 19, 2017
1 parent 7b1a0e5 commit c8a4313
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions telebot.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, BaseFilter
from telegram import ReplyKeyboardMarkup
import requests
class charFilter(BaseFilter):
def filter(self, message):
return len(message.text) == 1 and message.text in ['1','2','3','4']

entry = {}
keyboard = [['0', '1'], ['2', '3']]
url = '<URL>'
updater = Updater(token='<TOKEN>')
url = '<url>'
updater = Updater(token='<token>')
dispatcher = updater.dispatcher
charfilter = charFilter()


def generate_problem(username):
Expand Down Expand Up @@ -50,7 +54,7 @@ def reply_and_new_prob(bot, update):
bot.send_message(chat_id=update.message.chat_id, text=generate_problem(username))


dispatcher.add_handler(MessageHandler(Filters.text, reply_and_new_prob))
dispatcher.add_handler(MessageHandler(charfilter, reply_and_new_prob))
dispatcher.add_handler(CommandHandler('start', start))

updater.start_polling()
Expand Down

0 comments on commit c8a4313

Please sign in to comment.