mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-16 12:25:45 +01:00
flake8
This commit is contained in:
parent
d38add1a1c
commit
618df51811
3 changed files with 24 additions and 29 deletions
|
@ -50,9 +50,9 @@ from .bot import Bot
|
|||
from .broadcaster import Broadcaster
|
||||
from .boteventhandler import BotEventHandler
|
||||
|
||||
__all__ = ['Bot', 'BotEventHandler', 'Broadcaster', 'Emoji', 'TelegramError', 'InputFile', 'ReplyMarkup',
|
||||
'ForceReply', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup',
|
||||
'UserProfilePhotos', 'ChatAction', 'Location', 'Contact',
|
||||
'Video', 'Sticker', 'Document', 'File', 'Audio', 'PhotoSize',
|
||||
'GroupChat', 'Update', 'ParseMode', 'Message', 'User',
|
||||
'TelegramObject', 'NullHandler', 'Voice']
|
||||
__all__ = ['Bot', 'BotEventHandler', 'Broadcaster', 'Emoji', 'TelegramError',
|
||||
'InputFile', 'ReplyMarkup', 'ForceReply', 'ReplyKeyboardHide',
|
||||
'ReplyKeyboardMarkup', 'UserProfilePhotos', 'ChatAction',
|
||||
'Location', 'Contact', 'Video', 'Sticker', 'Document', 'File',
|
||||
'Audio', 'PhotoSize', 'GroupChat', 'Update', 'ParseMode', 'Message',
|
||||
'User', 'TelegramObject', 'NullHandler', 'Voice']
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This module contains the class BotEventHandler, which tries to make creating
|
||||
This module contains the class BotEventHandler, which tries to make creating
|
||||
|
||||
Telegram Bots intuitive!
|
||||
"""
|
||||
import logging
|
||||
|
@ -19,11 +20,6 @@ try:
|
|||
except ImportError:
|
||||
from queue import Queue
|
||||
|
||||
try:
|
||||
import BaseHTTPServer
|
||||
except ImportError:
|
||||
import http.server as BaseHTTPServer
|
||||
|
||||
H = NullHandler()
|
||||
logging.getLogger(__name__).addHandler(H)
|
||||
|
||||
|
@ -35,9 +31,9 @@ class BotEventHandler:
|
|||
can interact with the bot, for example on the command line. It supports
|
||||
Handlers for different kinds of data: Updates from Telegram, basic text
|
||||
commands and even arbitrary types.
|
||||
|
||||
Polling as well as webhook are supported.
|
||||
|
||||
|
||||
Attributes:
|
||||
|
||||
Args:
|
||||
|
@ -211,4 +207,3 @@ class BotEventHandler:
|
|||
self.broadcaster.stop()
|
||||
while broadcaster.running_async > 0:
|
||||
sleep(1)
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ class Broadcaster:
|
|||
break
|
||||
|
||||
self.processUpdate(update)
|
||||
|
||||
|
||||
# Broadcast any errors
|
||||
except TelegramError as te:
|
||||
self.broadcastError(update, te)
|
||||
|
@ -420,16 +420,16 @@ class Broadcaster:
|
|||
|
||||
def broadcastTelegramCommand(self, update):
|
||||
"""
|
||||
Broadcasts an update that contains a command.
|
||||
|
||||
Broadcasts an update that contains a command.
|
||||
|
||||
Args:
|
||||
command (str): The command keyword
|
||||
update (telegram.Update): The Telegram update that contains the
|
||||
command
|
||||
"""
|
||||
|
||||
|
||||
command = update.message.text.split(' ')[0][1:].split('@')[0]
|
||||
|
||||
|
||||
if command in self.telegram_command_handlers:
|
||||
self.broadcastTo(self.telegram_command_handlers[command], update)
|
||||
else:
|
||||
|
@ -454,17 +454,17 @@ class Broadcaster:
|
|||
matching_handlers.append(handler)
|
||||
|
||||
self.broadcastTo(matching_handlers, update)
|
||||
|
||||
|
||||
def broadcastStringCommand(self, update):
|
||||
"""
|
||||
Broadcasts a string-update that contains a command.
|
||||
|
||||
Broadcasts a string-update that contains a command.
|
||||
|
||||
Args:
|
||||
update (str): The string input
|
||||
"""
|
||||
|
||||
|
||||
command = update.split(' ')[0][1:]
|
||||
|
||||
|
||||
if command in self.string_command_handlers:
|
||||
self.broadcastTo(self.string_command_handlers[command], update)
|
||||
else:
|
||||
|
@ -493,7 +493,7 @@ class Broadcaster:
|
|||
def broadcastType(self, update):
|
||||
"""
|
||||
Broadcasts an update of any type.
|
||||
|
||||
|
||||
Args:
|
||||
update (any): The update
|
||||
"""
|
||||
|
@ -504,16 +504,16 @@ class Broadcaster:
|
|||
else:
|
||||
self.broadcastError(update, TelegramError(
|
||||
"Received update of unknown type %s" % type(update)))
|
||||
|
||||
|
||||
def broadcastTelegramMessage(self, update):
|
||||
"""
|
||||
Broadcasts an update that contains a regular message.
|
||||
|
||||
Broadcasts an update that contains a regular message.
|
||||
|
||||
Args:
|
||||
update (telegram.Update): The Telegram update that contains the
|
||||
message.
|
||||
"""
|
||||
|
||||
|
||||
self.broadcastTo(self.telegram_message_handlers, update)
|
||||
|
||||
def broadcastError(self, update, error):
|
||||
|
|
Loading…
Add table
Reference in a new issue