Skip to content

Commit

Permalink
Generate Pytdbot files
Browse files Browse the repository at this point in the history
  • Loading branch information
AYMENJD authored and github-actions[bot] committed Dec 29, 2023
1 parent 86b67c6 commit be10356
Show file tree
Hide file tree
Showing 4 changed files with 1,236 additions and 343 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.22-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
# Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.23-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)

Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.

Expand Down
172 changes: 118 additions & 54 deletions pytdbot/handlers/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,12 @@ def decorator(func: Callable) -> Callable:

return decorator

def on_updateChatAccentColor(
def on_updateChatAccentColors(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""A chat accent color has changed
"""Chat accent colors have changed
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
Expand All @@ -630,54 +630,14 @@ def decorator(func: Callable) -> Callable:
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler("updateChatAccentColor", func, filters, position)
self.add_handler("updateChatAccentColors", func, filters, position)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(func, "updateChatAccentColor", self, position)
func._handler = Handler(func, "updateChatAccentColors", self, position)
else:
func._handler = Handler(
func, "updateChatAccentColor", filters, position
)
return func

return decorator

def on_updateChatBackgroundCustomEmoji(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""A chat's custom emoji for reply background has changed
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
An update filter
position (``int``, *optional*):
The function position in handlers list. Default is ``None`` (append)
Raises:
:py:class:`TypeError`
"""

def decorator(func: Callable) -> Callable:
if hasattr(func, "_handler"):
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler(
"updateChatBackgroundCustomEmoji", func, filters, position
)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(
func, "updateChatBackgroundCustomEmoji", self, position
)
else:
func._handler = Handler(
func, "updateChatBackgroundCustomEmoji", filters, position
func, "updateChatAccentColors", filters, position
)
return func

Expand Down Expand Up @@ -967,6 +927,42 @@ def decorator(func: Callable) -> Callable:

return decorator

def on_updateChatEmojiStatus(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""Chat emoji status has changed
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
An update filter
position (``int``, *optional*):
The function position in handlers list. Default is ``None`` (append)
Raises:
:py:class:`TypeError`
"""

def decorator(func: Callable) -> Callable:
if hasattr(func, "_handler"):
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler("updateChatEmojiStatus", func, filters, position)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(func, "updateChatEmojiStatus", self, position)
else:
func._handler = Handler(
func, "updateChatEmojiStatus", filters, position
)
return func

return decorator

def on_updateChatMessageSender(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
Expand Down Expand Up @@ -3377,12 +3373,12 @@ def decorator(func: Callable) -> Callable:

return decorator

def on_updateSelectedBackground(
def on_updateDefaultBackground(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""The selected background has changed
"""The default background has changed
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
Expand All @@ -3400,18 +3396,14 @@ def decorator(func: Callable) -> Callable:
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler(
"updateSelectedBackground", func, filters, position
)
self.add_handler("updateDefaultBackground", func, filters, position)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(
func, "updateSelectedBackground", self, position
)
func._handler = Handler(func, "updateDefaultBackground", self, position)
else:
func._handler = Handler(
func, "updateSelectedBackground", filters, position
func, "updateDefaultBackground", filters, position
)
return func

Expand Down Expand Up @@ -4601,6 +4593,78 @@ def decorator(func: Callable) -> Callable:

return decorator

def on_updateMessageReaction(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""User changed its reactions on a message with public reactions; for bots only
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
An update filter
position (``int``, *optional*):
The function position in handlers list. Default is ``None`` (append)
Raises:
:py:class:`TypeError`
"""

def decorator(func: Callable) -> Callable:
if hasattr(func, "_handler"):
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler("updateMessageReaction", func, filters, position)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(func, "updateMessageReaction", self, position)
else:
func._handler = Handler(
func, "updateMessageReaction", filters, position
)
return func

return decorator

def on_updateMessageReactions(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
position: int = None,
) -> Callable:
"""Reactions added to a message with anonymous reactions have changed; for bots only
Args:
filters (:class:`pytdbot.filters.Filter`, *optional*):
An update filter
position (``int``, *optional*):
The function position in handlers list. Default is ``None`` (append)
Raises:
:py:class:`TypeError`
"""

def decorator(func: Callable) -> Callable:
if hasattr(func, "_handler"):
return func
elif isinstance(self, pytdbot.Client):
if iscoroutinefunction(func):
self.add_handler("updateMessageReactions", func, filters, position)
else:
raise TypeError("Handler must be async")
elif isinstance(self, pytdbot.filters.Filter):
func._handler = Handler(func, "updateMessageReactions", self, position)
else:
func._handler = Handler(
func, "updateMessageReactions", filters, position
)
return func

return decorator

def on_updates(
self: "pytdbot.Client" = None,
filters: "pytdbot.filters.Filter" = None,
Expand Down
Loading

0 comments on commit be10356

Please sign in to comment.