mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1237 from monosans/comprehension
Replace for loops with comprehensions
This commit is contained in:
commit
7914f71938
@ -359,10 +359,7 @@ class TeleBot:
|
|||||||
:return: array of Updates
|
:return: array of Updates
|
||||||
"""
|
"""
|
||||||
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
|
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
|
||||||
ret = []
|
return [types.Update.de_json(ju) for ju in json_updates]
|
||||||
for ju in json_updates:
|
|
||||||
ret.append(types.Update.de_json(ju))
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def __skip_updates(self):
|
def __skip_updates(self):
|
||||||
"""
|
"""
|
||||||
@ -832,10 +829,7 @@ class TeleBot:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
result = apihelper.get_chat_administrators(self.token, chat_id)
|
result = apihelper.get_chat_administrators(self.token, chat_id)
|
||||||
ret = []
|
return [types.ChatMember.de_json(r) for r in result]
|
||||||
for r in result:
|
|
||||||
ret.append(types.ChatMember.de_json(r))
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def get_chat_members_count(self, chat_id: Union[int, str]) -> int:
|
def get_chat_members_count(self, chat_id: Union[int, str]) -> int:
|
||||||
"""
|
"""
|
||||||
@ -1307,10 +1301,7 @@ class TeleBot:
|
|||||||
result = apihelper.send_media_group(
|
result = apihelper.send_media_group(
|
||||||
self.token, chat_id, media, disable_notification, reply_to_message_id, timeout,
|
self.token, chat_id, media, disable_notification, reply_to_message_id, timeout,
|
||||||
allow_sending_without_reply)
|
allow_sending_without_reply)
|
||||||
ret = []
|
return [types.Message.de_json(msg) for msg in result]
|
||||||
for msg in result:
|
|
||||||
ret.append(types.Message.de_json(msg))
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def send_location(
|
def send_location(
|
||||||
self, chat_id: Union[int, str],
|
self, chat_id: Union[int, str],
|
||||||
@ -1962,10 +1953,7 @@ class TeleBot:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
result = apihelper.get_game_high_scores(self.token, user_id, chat_id, message_id, inline_message_id)
|
result = apihelper.get_game_high_scores(self.token, user_id, chat_id, message_id, inline_message_id)
|
||||||
ret = []
|
return [types.GameHighScore.de_json(r) for r in result]
|
||||||
for r in result:
|
|
||||||
ret.append(types.GameHighScore.de_json(r))
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def send_invoice(
|
def send_invoice(
|
||||||
self, chat_id: Union[int, str], title: str, description: str,
|
self, chat_id: Union[int, str], title: str, description: str,
|
||||||
|
@ -81,13 +81,10 @@ class JsonDeserializable(object):
|
|||||||
raise ValueError("json_type should be a json dict or string.")
|
raise ValueError("json_type should be a json dict or string.")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
d = {}
|
d = {
|
||||||
for x, y in self.__dict__.items():
|
x: y.__dict__ if hasattr(y, '__dict__') else y
|
||||||
if hasattr(y, '__dict__'):
|
for x, y in self.__dict__.items()
|
||||||
d[x] = y.__dict__
|
}
|
||||||
else:
|
|
||||||
d[x] = y
|
|
||||||
|
|
||||||
return str(d)
|
return str(d)
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,9 +351,10 @@ def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int=2) -> types.I
|
|||||||
:return: InlineKeyboardMarkup
|
:return: InlineKeyboardMarkup
|
||||||
"""
|
"""
|
||||||
markup = types.InlineKeyboardMarkup(row_width=row_width)
|
markup = types.InlineKeyboardMarkup(row_width=row_width)
|
||||||
buttons = []
|
buttons = [
|
||||||
for text, kwargs in values.items():
|
types.InlineKeyboardButton(text=text, **kwargs)
|
||||||
buttons.append(types.InlineKeyboardButton(text=text, **kwargs))
|
for text, kwargs in values.items()
|
||||||
|
]
|
||||||
markup.add(*buttons)
|
markup.add(*buttons)
|
||||||
return markup
|
return markup
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user