mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 09:49:21 +01:00
* Remove non-pep8 dispatcher methods * callbackqueryhandler: Remove non-pep8 compliant methods * commandhandler: Remove non-pep8 compliant methods * handler: Remove non-pep8 compliant methods * messagehandler: Remove non-pep8 compliant methods * stringcommandhandler: Remove non-pep8 compliant methods * stringregexhandler: Remove non-pep8 compliant methods * test_updater: fix usage of deprecated methods * dispatcher: fix accidental misalignment of comments by pre-commit hook * Add myself to list of contributors
This commit is contained in:
parent
90bf26c09b
commit
11a3de67ea
9 changed files with 6 additions and 53 deletions
|
@ -32,6 +32,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
|||
- `macrojames <https://github.com/macrojames>`_
|
||||
- `Michael Elovskikh <https://github.com/wronglink>`_
|
||||
- `naveenvhegde <https://github.com/naveenvhegde>`_
|
||||
- `neurrone <https://github.com/neurrone>`_
|
||||
- `njittam <https://github.com/njittam>`_
|
||||
- `Noam Meltzer <https://github.com/tsnoam>`_
|
||||
- `Oleg Shlyazhko <https://github.com/ollmer>`_
|
||||
|
|
|
@ -23,7 +23,6 @@ import re
|
|||
from future.utils import string_types
|
||||
|
||||
from telegram import Update
|
||||
from telegram.utils.deprecate import deprecate
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
|
@ -105,8 +104,3 @@ class CallbackQueryHandler(Handler):
|
|||
optional_args['groupdict'] = match.groupdict()
|
||||
|
||||
return self.callback(dispatcher.bot, update, **optional_args)
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.CallbackQueryHandler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
|
|
|
@ -21,7 +21,6 @@ import warnings
|
|||
|
||||
from .handler import Handler
|
||||
from telegram import Update
|
||||
from telegram.utils.deprecate import deprecate
|
||||
|
||||
|
||||
class CommandHandler(Handler):
|
||||
|
@ -126,8 +125,3 @@ class CommandHandler(Handler):
|
|||
optional_args['args'] = message.text.split()[1:]
|
||||
|
||||
return self.callback(dispatcher.bot, update, **optional_args)
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.CommandHandler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
|
|
|
@ -32,7 +32,6 @@ from future.builtins import range
|
|||
|
||||
from telegram import TelegramError
|
||||
from telegram.ext.handler import Handler
|
||||
from telegram.utils.deprecate import deprecate
|
||||
from telegram.utils.promise import Promise
|
||||
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
@ -368,11 +367,3 @@ class Dispatcher(object):
|
|||
|
||||
for callback in self.error_handlers:
|
||||
callback(self.bot, update, error)
|
||||
|
||||
# old non-PEP8 Dispatcher methods
|
||||
m = "telegram.dispatcher."
|
||||
addHandler = deprecate(add_handler, m + "AddHandler", m + "add_handler")
|
||||
removeHandler = deprecate(remove_handler, m + "removeHandler", m + "remove_handler")
|
||||
addErrorHandler = deprecate(add_error_handler, m + "addErrorHandler", m + "add_error_handler")
|
||||
removeErrorHandler = deprecate(remove_error_handler, m + "removeErrorHandler",
|
||||
m + "remove_error_handler")
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
""" This module contains the base class for handlers as used by the
|
||||
Dispatcher """
|
||||
|
||||
from telegram.utils.deprecate import deprecate
|
||||
|
||||
|
||||
class Handler(object):
|
||||
"""
|
||||
|
@ -114,10 +112,3 @@ class Handler(object):
|
|||
optional_args['chat_data'] = dispatcher.chat_data[chat.id if chat else None]
|
||||
|
||||
return optional_args
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.Handler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
collectOptionalArgs = deprecate(collect_optional_args, m + "collectOptionalArgs",
|
||||
m + "collect_optional_args")
|
||||
|
|
|
@ -21,7 +21,6 @@ import warnings
|
|||
|
||||
from .handler import Handler
|
||||
from telegram import Update
|
||||
from telegram.utils.deprecate import deprecate
|
||||
|
||||
|
||||
class MessageHandler(Handler):
|
||||
|
@ -120,8 +119,3 @@ class MessageHandler(Handler):
|
|||
optional_args = self.collect_optional_args(dispatcher, update)
|
||||
|
||||
return self.callback(dispatcher.bot, update, **optional_args)
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.MessageHandler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
""" This module contains the StringCommandHandler class """
|
||||
|
||||
from .handler import Handler
|
||||
from telegram.utils.deprecate import deprecate
|
||||
|
||||
|
||||
class StringCommandHandler(Handler):
|
||||
|
@ -69,8 +68,3 @@ class StringCommandHandler(Handler):
|
|||
optional_args['args'] = update.split()[1:]
|
||||
|
||||
return self.callback(dispatcher.bot, update, **optional_args)
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.StringCommandHandler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
|
|
|
@ -23,7 +23,6 @@ import re
|
|||
from future.utils import string_types
|
||||
|
||||
from .handler import Handler
|
||||
from telegram.utils.deprecate import deprecate
|
||||
|
||||
|
||||
class StringRegexHandler(Handler):
|
||||
|
@ -84,8 +83,3 @@ class StringRegexHandler(Handler):
|
|||
optional_args['groupdict'] = match.groupdict()
|
||||
|
||||
return self.callback(dispatcher.bot, update, **optional_args)
|
||||
|
||||
# old non-PEP8 Handler methods
|
||||
m = "telegram.StringRegexHandler."
|
||||
checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update")
|
||||
handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update")
|
||||
|
|
|
@ -189,15 +189,15 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
d = self.updater.dispatcher
|
||||
from telegram.ext import Filters
|
||||
handler = MessageHandler(Filters.text, self.telegramHandlerEditedTest, allow_edited=True)
|
||||
d.addHandler(handler)
|
||||
d.add_handler(handler)
|
||||
self.updater.start_polling(0.01)
|
||||
sleep(.1)
|
||||
self.assertEqual(self.received_message, 'Test')
|
||||
|
||||
# Remove handler
|
||||
d.removeHandler(handler)
|
||||
d.remove_handler(handler)
|
||||
handler = MessageHandler(Filters.text, self.telegramHandlerEditedTest, allow_edited=False)
|
||||
d.addHandler(handler)
|
||||
d.add_handler(handler)
|
||||
self.reset()
|
||||
|
||||
self.updater.bot.send_messages = 1
|
||||
|
@ -263,9 +263,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(None is self.received_message)
|
||||
|
||||
# Remove handler
|
||||
d.removeHandler(handler)
|
||||
d.remove_handler(handler)
|
||||
handler = CommandHandler('test', self.telegramHandlerEditedTest, allow_edited=False)
|
||||
d.addHandler(handler)
|
||||
d.add_handler(handler)
|
||||
self.reset()
|
||||
|
||||
self.updater.bot.send_messages = 1
|
||||
|
|
Loading…
Reference in a new issue