1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1 from eternnoir/master

Merging to master
This commit is contained in:
Sergey 2017-05-19 16:22:07 +03:00 committed by GitHub
commit 5969a6644c
3 changed files with 92 additions and 5 deletions

View File

@ -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.

View File

@ -45,7 +45,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.
@ -76,7 +76,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)
@ -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)

View File

@ -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):