Skip to content

Commit

Permalink
Merge pull request #35 from HexyeDEV/restyled/v0.3.2
Browse files Browse the repository at this point in the history
Restyle v0.3.2
  • Loading branch information
HexyeDEV authored Jun 29, 2023
2 parents a80b659 + 6c58429 commit f4b1e29
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 30 deletions.
6 changes: 4 additions & 2 deletions EzTg/EzTg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import aiohttp
import asyncio

import aiohttp

from .types.chat.chat import Chat
from .types.user.user import User

Expand Down Expand Up @@ -79,7 +80,8 @@ async def start_polling(self, callback, callback_query=None):
offset = update[-1].update_id + 1
elif "callback_query" in x.keys() and callback_query:
try:
asyncio.get_event_loop().create_task(callback_query(x))
asyncio.get_event_loop().create_task(
callback_query(x))
except Exception as e:
raise e
finally:
Expand Down
2 changes: 1 addition & 1 deletion EzTg/types/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
from .venue import Venue
from .video import Video
from .videonote import VideoNote
from .voice import Voice
from .voice import Voice
6 changes: 3 additions & 3 deletions EzTg/types/message/contact.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Contact:
"""This object represents a phone contact.
Attributes
----------
phone_number: `str`
Expand All @@ -13,10 +13,10 @@ class Contact:
Optional. Contact's user identifier in Telegram.
vcard: `str`
Optional. Additional data about the contact in the form of a vCard."""

def __init__(self, data):
self.phone_number = data["phone_number"]
self.first_name = data["first_name"]
self.last_name = data.get("last_name")
self.user_id = data.get("user_id")
self.vcard = data.get("vcard")
self.vcard = data.get("vcard")
4 changes: 2 additions & 2 deletions EzTg/types/message/dice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Dice:
"""This object represents an animated emoji that displays a random value.
Attributes
----------
emoji: `str`
Expand All @@ -11,4 +11,4 @@ class Dice:

def __init__(self, data):
self.emoji = data["emoji"]
self.value = data["value"]
self.value = data["value"]
4 changes: 2 additions & 2 deletions EzTg/types/message/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class File:
"""This object represents a file ready to be downloaded. The file can be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling `getFile`.
Attributes
----------
file_id: `str`
Expand All @@ -17,4 +17,4 @@ def __init__(self, data):
self.file_id = data["file_id"]
self.file_unique_id = data["file_unique_id"]
self.file_size = data.get("file_size")
self.file_path = data.get("file_path")
self.file_path = data.get("file_path")
11 changes: 7 additions & 4 deletions EzTg/types/message/game.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .animation import Animation
from .photosize import PhotoSize
from .messageentity import MessageEntity
from .photosize import PhotoSize


class Game:
"""This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
Attributes
----------
title: `str`
Expand All @@ -26,5 +27,7 @@ def __init__(self, data):
self.description = data["description"]
self.photo = [PhotoSize(photo) for photo in data["photo"]]
self.text = data.get("text")
self.text_entities = [MessageEntity(entity) for entity in data.get("text_entities", [])]
self.animation = Animation(data.get("animation"))
self.text_entities = [
MessageEntity(entity) for entity in data.get("text_entities", [])
]
self.animation = Animation(data.get("animation"))
4 changes: 2 additions & 2 deletions EzTg/types/message/maskposition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MaskPosition:
"""Represents a point on the mask position of a sticker sent by the bot.
Attributes
----------
point: `str`
Expand All @@ -17,4 +17,4 @@ def __init__(self, data):
self.point = data["point"]
self.x_shift = data["x_shift"]
self.y_shift = data["y_shift"]
self.scale = data["scale"]
self.scale = data["scale"]
3 changes: 1 addition & 2 deletions EzTg/types/message/message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..chat.chat import Chat
from ..inlinekeyboard import InlineKeyboard
from ..location import Location
from ..user.user import User
from .animation import Animation
Expand All @@ -7,7 +8,6 @@
from .dice import Dice
from .document import Document
from .game import Game
from ..inlinekeyboard import InlineKeyboard
from .messageentity import MessageEntity
from .photosize import PhotoSize
from .poll import Poll
Expand Down Expand Up @@ -203,4 +203,3 @@ def __init__(self, data):
self.reply_markup = data.get("reply_markup")
if self.reply_markup:
self.reply_markup = InlineKeyboard(self.reply_markup)

15 changes: 10 additions & 5 deletions EzTg/types/message/poll.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from .messageentity import MessageEntity
from .polloption import PollOption


class Poll:
"""This object contains information about a poll.
Attributes
----------
id: `str`
Expand Down Expand Up @@ -31,8 +32,9 @@ class Poll:
open_period: `int`
Optional. Amount of time in seconds the poll will be active after creation.
close_date: `int`
Optional. Point in time (Unix timestamp) when the poll will be automatically closed."""

Optional. Point in time (Unix timestamp) when the poll will be automatically closed.
"""

def __init__(self, data):
self.id = data["id"]
self.question = data["question"]
Expand All @@ -44,6 +46,9 @@ def __init__(self, data):
self.allows_multiple_answers = data["allows_multiple_answers"]
self.correct_option_id = data.get("correct_option_id")
self.explanation = data.get("explanation")
self.explanation_entities = [MessageEntity(entity) for entity in data.get("explanation_entities", [])]
self.explanation_entities = [
MessageEntity(entity)
for entity in data.get("explanation_entities", [])
]
self.open_period = data.get("open_period")
self.close_date = data.get("close_date")
self.close_date = data.get("close_date")
6 changes: 3 additions & 3 deletions EzTg/types/message/polloption.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class PollOption:
"""Represents one answer option in a poll.
Attributes
----------
text: `str`
Option text, 1-100 characters.
voter_count: `int`
Number of users that voted for this option"""

def __init__(self, data):
self.text = data["text"]
self.voter_count = data["voter_count"]
self.voter_count = data["voter_count"]
5 changes: 3 additions & 2 deletions EzTg/types/message/sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from .maskposition import MaskPosition
from .photosize import PhotoSize


class Sticker:
"""This object represents a sticker.
Attributes
----------
file_id: `str`
Expand Down Expand Up @@ -60,4 +61,4 @@ def __init__(self, data):
self.mask_position = MaskPosition(self.mask_position)
self.custom_emoji_id = data.get("custom_emoji_id")
self.needs_repainting = data.get("needs_repainting")
self.file_size = data.get("file_size")
self.file_size = data.get("file_size")
5 changes: 3 additions & 2 deletions EzTg/types/message/venue.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from ..location import Location


class Venue:
"""This object represents a venue.
Attributes
----------
location: `Location`
Expand All @@ -28,4 +29,4 @@ def __init__(self, data):
self.foursquare_id = data.get("foursquare_id")
self.foursquare_type = data.get("foursquare_type")
self.google_place_id = data.get("google_place_id")
self.google_place_type = data.get("google_place_type")
self.google_place_type = data.get("google_place_type")

0 comments on commit f4b1e29

Please sign in to comment.