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

Add 2.1 new method.

This commit is contained in:
eternnoir 2016-06-07 19:00:44 +08:00
parent ddd3664329
commit d2e7f4d8f2
3 changed files with 63 additions and 0 deletions

View File

@ -285,6 +285,26 @@ class TeleBot:
result = apihelper.get_user_profile_photos(self.token, user_id, offset, limit)
return types.UserProfilePhotos.de_json(result)
def get_chat(self, chat_id):
result = apihelper.get_chat(self.token, chat_id)
return types.Chat.de_json(result)
def leave_chat(self, chat_id):
result = apihelper.leave_chat(self.token, chat_id)
return result
def get_chat_administrators(self, chat_id):
result = apihelper.get_chat_administrators(self.token, chat_id)
return [[types.ChatMember.de_json(y) for y in x] for x in result]
def get_chat_members_count(self, chat_id):
result = apihelper.get_chat_members_count(self.token, chat_id)
return result
def get_chat_member(self, chat_id, user_id):
result = apihelper.get_chat_member(self.token, chat_id,user_id)
return types.ChatMember.de_json(result)
def send_message(self, chat_id, text, disable_web_page_preview=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None):
"""

View File

@ -149,6 +149,36 @@ def get_user_profile_photos(token, user_id, offset=None, limit=None):
return _make_request(token, method_url, params=payload)
def get_chat(token, chat_id):
method_url = r'getChat'
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload)
def leave_chat(token, chat_id):
method_url = r'leaveChat'
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload)
def get_chat_administrators(token, chat_id):
method_url = r'getChatAdministrators'
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload)
def get_chat_members_count(token, chat_id):
method_url = r'getChatMembersCount'
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload)
def get_chat_member(token, chat_id, user_id):
method_url = r'getChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
return _make_request(token, method_url, params=payload)
def forward_message(token, chat_id, from_chat_id, message_id, disable_notification=None):
method_url = r'forwardMessage'
payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id}

View File

@ -721,6 +721,19 @@ class CallbackQuery(JsonDeserializable):
self.inline_message_id = inline_message_id
class ChatMember(JsonDeserializable):
@classmethod
def de_json(cls, json_type):
obj = cls.check_json(json_type)
user = User.de_json(obj['user'])
status = obj['status']
return cls(id, user, status)
def __init__(self, user, status):
self.user = user
self.status = status
# InlineQuery
class InlineQuery(JsonDeserializable):