Skip to content

Commit

Permalink
Merge pull request #16 from HexyeDEV/restyled/v0.3.2
Browse files Browse the repository at this point in the history
Restyle add User class
  • Loading branch information
HexyeDEV authored Jan 18, 2023
2 parents c7f1528 + c2e574c commit 1ea736f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
16 changes: 13 additions & 3 deletions EzTg/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import aiohttp
import requests

from .user import User


Expand Down Expand Up @@ -377,7 +378,7 @@ async def get_chat_id(self, message):
message: `dict`
The message object.s"""
return message["chat"]["id"]

async def get_sender_object(self, message):
"""Get sender object from message.
Expand All @@ -386,5 +387,14 @@ async def get_sender_object(self, message):
message: `dict`
The message object."""
sender = message["from"]
user = User(sender["id"], sender["id_bot"], sender["first_name"], sender["last_name"], sender["username"], sender["language_code"], sender["is_premium"], sender["added_to_attachment_menu"])
return user
user = User(
sender["id"],
sender["id_bot"],
sender["first_name"],
sender["last_name"],
sender["username"],
sender["language_code"],
sender["is_premium"],
sender["added_to_attachment_menu"],
)
return user
20 changes: 17 additions & 3 deletions EzTg/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class User:
"""Represents a Telegram user or bot.
Attributes
----------
id: `int`
Expand All @@ -25,7 +25,21 @@ class User:
Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
supports_inline_queries: `bool`
Optional. True, if the bot supports inline queries. Returned only in getMe."""
def __init__(self, id, is_bot, first_name, last_name, username, language_code, is_premium, added_to_attachment_menu, can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None):

def __init__(
self,
id,
is_bot,
first_name,
last_name,
username,
language_code,
is_premium,
added_to_attachment_menu,
can_join_groups=None,
can_read_all_group_messages=None,
supports_inline_queries=None,
):
self.id = id
self.is_bot = is_bot
self.first_name = first_name
Expand All @@ -36,4 +50,4 @@ def __init__(self, id, is_bot, first_name, last_name, username, language_code, i
self.added_to_attachment_menu = added_to_attachment_menu
self.can_join_groups = can_join_groups
self.can_read_all_group_messages = can_read_all_group_messages
self.supports_inline_queries = supports_inline_queries
self.supports_inline_queries = supports_inline_queries

0 comments on commit 1ea736f

Please sign in to comment.