Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle add User class #16

Merged
merged 4 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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