From e138d2e1ef7a6f1d74ae48e2ff088f7d878eff65 Mon Sep 17 00:00:00 2001 From: Artom-Kozincev Date: Thu, 6 Apr 2017 22:12:17 +0300 Subject: [PATCH 1/4] Add more accurate control over threads count --- telebot/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 3b70be9..8d861d4 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -44,7 +44,7 @@ class TeleBot: getUpdates """ - def __init__(self, token, threaded=True, skip_pending=False): + def __init__(self, token, threaded=True, skip_pending=False, num_threads=2): """ :param token: bot API token :return: Telebot object. @@ -75,7 +75,7 @@ class TeleBot: self.threaded = threaded if self.threaded: - self.worker_pool = util.ThreadPool() + self.worker_pool = util.ThreadPool(num_threads=num_threads) def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None): return apihelper.set_webhook(self.token, url, certificate, max_connections, allowed_updates) From b91eeb27526fcc48d44be1fbaca21ae15a87663e Mon Sep 17 00:00:00 2001 From: jiwidi Date: Sun, 7 May 2017 18:27:04 +0200 Subject: [PATCH 2/4] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ab000ac..9f446fd 100644 --- a/README.md +++ b/README.md @@ -542,7 +542,8 @@ Get help. Discuss. Chat. * [proxybot](https://github.com/p-hash/proxybot) - Simple Proxy Bot for Telegram. by p-hash * [DonantesMalagaBot](https://github.com/vfranch/DonantesMalagaBot)- DonantesMalagaBot facilitates information to Malaga blood donors about the places where they can donate today or in the incoming days. It also records the date of the last donation so that it helps the donors to know when they can donate again. - by vfranch * [DuttyBot](https://github.com/DmytryiStriletskyi/DuttyBot) by *Dmytryi Striletskyi* - Timetable for one university in Kiev. -* [dailypepebot](https://telegram.me/dailypepebot) by [*jaime*](https://github.com/jiwidi) - Get's you random pepe images and gives you their id, then you can call this image with the number. +* [dailypepebot](https://telegram.me/dailypepebot) by [*Jaime*](https://github.com/jiwidi/Dailypepe) - Get's you random pepe images and gives you their id, then you can call this image with the number. +* [DailyQwertee](https://t.me/DailyQwertee) by [*Jaime*](https://github.com/jiwidi/DailyQwertee) - Bot that manages a channel that sends qwertee daily tshirts every day at 00:00 * [wat-bridge](https://github.com/rmed/wat-bridge) by [*rmed*](https://github.com/rmed) - Send and receive messages to/from WhatsApp through Telegram * [flibusta_bot](https://github.com/Kurbezz/flibusta_bot) by [*Kurbezz*](https://github.com/Kurbezz) * [EmaProject](https://github.com/halkliff/emaproject) by [*halkliff*](https://github.com/halkliff) - Ema - Eastern Media Assistant was made thinking on the ease-to-use feature. Coding here is simple, as much as is fast and powerful. From 34047c0121e3530499ccad70346eb022c8462e65 Mon Sep 17 00:00:00 2001 From: Kurbanov Bulat Date: Thu, 18 May 2017 13:55:55 +0400 Subject: [PATCH 3/4] Add methods to AsyncTeleBot --- telebot/__init__.py | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/telebot/__init__.py b/telebot/__init__.py index ec731de..da2d0fe 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -885,10 +885,38 @@ class AsyncTeleBot(TeleBot): def get_me(self): return TeleBot.get_me(self) + @util.async() + def get_file(self, *args): + return TeleBot.get_file(self, *args) + + @util.async() + def download_file(self, *args): + return TeleBot.download_file(self, *args) + @util.async() def get_user_profile_photos(self, *args, **kwargs): return TeleBot.get_user_profile_photos(self, *args, **kwargs) + @util.async() + def get_chat(self, *args): + return TeleBot.get_chat(self, *args) + + @util.async() + def leave_chat(self, *args): + return TeleBot.leave_chat(self, *args) + + @util.async() + def get_chat_administrators(self, *args): + return TeleBot.get_chat_administrators(self, *args) + + @util.async() + def get_chat_members_count(self, *args): + return TeleBot.get_chat_members_count(self, *args) + + @util.async() + def get_chat_member(self, *args): + return TeleBot.get_chat_member(self, *args) + @util.async() def send_message(self, *args, **kwargs): return TeleBot.send_message(self, *args, **kwargs) @@ -897,6 +925,10 @@ class AsyncTeleBot(TeleBot): def forward_message(self, *args, **kwargs): return TeleBot.forward_message(self, *args, **kwargs) + @util.async() + def delete_message(self, *args): + return TeleBot.delete_message(self, *args) + @util.async() def send_photo(self, *args, **kwargs): return TeleBot.send_photo(self, *args, **kwargs) @@ -905,6 +937,10 @@ class AsyncTeleBot(TeleBot): def send_audio(self, *args, **kwargs): return TeleBot.send_audio(self, *args, **kwargs) + @util.async() + def send_voice(self, *args, **kwargs): + return TeleBot.send_voice(self, *args, **kwargs) + @util.async() def send_document(self, *args, **kwargs): return TeleBot.send_document(self, *args, **kwargs) @@ -921,6 +957,54 @@ class AsyncTeleBot(TeleBot): def send_location(self, *args, **kwargs): return TeleBot.send_location(self, *args, **kwargs) + @util.async() + def send_venue(self, *args, **kwargs): + return TeleBot.send_venue(self, *args, **kwargs) + + @util.async() + def send_contact(self, *args, **kwargs): + return TeleBot.send_contact(self, *args, **kwargs) + @util.async() def send_chat_action(self, *args, **kwargs): return TeleBot.send_chat_action(self, *args, **kwargs) + + @util.async() + def kick_chat_member(self, *args): + return TeleBot.kick_chat_member(self, *args) + + @util.async() + def unban_chat_member(self, *args): + return TeleBot.unban_chat_member(self, *args) + + @util.async() + def edit_message_text(self, *args, **kwargs): + return TeleBot.edit_message_text(self, *args, **kwargs) + + @util.async() + def edit_message_reply_markup(self, *args, **kwargs): + return TeleBot.edit_message_reply_markup(self, *args, **kwargs) + + @util.async() + def send_game(self, *args, **kwargs): + return TeleBot.send_game(self, *args, **kwargs) + + @util.async() + def set_game_score(self, *args, **kwargs): + return TeleBot.set_game_score(self, *args, **kwargs) + + @util.async() + def get_game_high_scores(self, *args, **kwargs): + return TeleBot.get_game_high_scores(self, *args, **kwargs) + + @util.async() + def edit_message_caption(self, *args, **kwargs): + return TeleBot.edit_message_caption(self, *args, **kwargs) + + @util.async() + def answer_inline_query(self, *args, **kwargs): + return TeleBot.answer_inline_query(self, *args, **kwargs) + + @util.async() + def answer_callback_query(self, *args, **kwargs): + return TeleBot.answer_callback_query(self, *args, **kwargs) From 35214b12707576e1adc11a712522dceca2129505 Mon Sep 17 00:00:00 2001 From: i32ropie Date: Thu, 18 May 2017 23:40:10 +0200 Subject: [PATCH 4/4] Added language code for users --- telebot/types.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index a8d2ef5..497996f 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -168,13 +168,15 @@ class User(JsonDeserializable): first_name = obj['first_name'] last_name = obj.get('last_name') username = obj.get('username') - return cls(id, first_name, last_name, username) + language_code = obj.get('language_code') + return cls(id, first_name, last_name, username, language_code) - def __init__(self, id, first_name, last_name=None, username=None): + def __init__(self, id, first_name, last_name=None, username=None, language_code=None): self.id = id self.first_name = first_name self.username = username self.last_name = last_name + self.language_code = language_code class GroupChat(JsonDeserializable):