Skip to content
This repository has been archived by the owner on May 7, 2018. It is now read-only.

Commit

Permalink
Add chat.administrators function
Browse files Browse the repository at this point in the history
  • Loading branch information
vijfhoek committed Nov 9, 2017
1 parent 0be96be commit 244c7ed
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ def __init__(self, bot, data):
self.last_name = data.get("last_name")
self.username = data.get("username")

class ChatMember:
def __init__(self, bot, data):
self.user = parse_object(bot, data, "user", User)
self.status = data.get("status")
self.until_date = data.get("until_date")
self.can_be_edited = data.get("can_be_edited")
self.can_change_info = data.get("can_change_info")
self.can_post_messages = data.get("can_post_messages")
self.can_edit_messages = data.get("can_edit_messages")
self.can_delete_messages = data.get("can_delete_messages")
self.can_invite_users = data.get("can_invite_users")
self.can_restrict_members = data.get("can_restrict_members")
self.can_pin_messages = data.get("can_pin_messages")
self.can_promote_members = data.get("can_promote_members")
self.can_send_messages = data.get("can_send_messages")
self.can_send_media_messages = data.get("can_send_media_messages")
self.can_send_other_messages = data.get("can_send_other_messages")
self.can_add_web_page_previews = data.get("can_add_web_page_previews")

class Chat:
def __init__(self, bot, data):
self.bot = bot
Expand All @@ -30,6 +49,10 @@ def __init__(self, bot, data):
async def message(self, text, **kwargs):
await self.bot.api_call("sendMessage", text = text, chat_id = self.id, **kwargs)

async def administrators(self):
data = await self.bot.api_call("getChatAdministrators", chat_id = self.id)
return [ChatMember(self.bot, member) for member in data]

def command(self, command):
def wrap(handler):
self.bot.cmd_handlers[self.id, command.lower()] = handler
Expand Down

0 comments on commit 244c7ed

Please sign in to comment.