Skip to content

Commit

Permalink
add User class
Browse files Browse the repository at this point in the history
  • Loading branch information
HexyeDEV committed Jan 18, 2023
1 parent 43dd491 commit c7f1528
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
12 changes: 12 additions & 0 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


class Parse(dict):
Expand Down Expand Up @@ -376,3 +377,14 @@ 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.
Parameters
----------
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
39 changes: 39 additions & 0 deletions EzTg/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class User:
"""Represents a Telegram user or bot.
Attributes
----------
id: `int`
The unique identifier for this user or bot.
is_bot: `bool`
True, if this user is a bot.
first_name: `str`
User's or bot's first name.
last_name: `str`
User's or bot's last name.
username: `str`
User's or bot's username.
language_code: `str`
IETF language tag of the user's language.
is_premium: `bool`
True, if this user is a Telegram Premium user
added_to_attachment_menu: `bool`
True, if this user added the bot to the attachment menu
can_join_groups: `bool`
Optional. True, if the bot can be invited to groups. Returned only in getMe.
can_read_all_group_messages: `bool`
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):
self.id = id
self.is_bot = is_bot
self.first_name = first_name
self.last_name = last_name
self.username = username
self.language_code = language_code
self.is_premium = is_premium
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setuptools.setup(
name="EzTg",
version="0.2.2",
version="0.3.2",
author="Hexye",
author_email="[email protected]",
description=
Expand Down

0 comments on commit c7f1528

Please sign in to comment.