botapi-py 1.3.1__tar.gz → 1.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: botapi-py
3
- Version: 1.3.1
3
+ Version: 1.3.3
4
4
  Summary: A simple and flexible Python library to conveniently build Telegram bots using the Bot API.
5
5
  Requires-Dist: httpx>=0.28.1
6
6
  Requires-Dist: pydantic>=2.12.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "botapi-py"
3
- version = "1.3.1"
3
+ version = "1.3.3"
4
4
  description = "A simple and flexible Python library to conveniently build Telegram bots using the Bot API."
5
5
  # readme = "README.md"
6
6
  # authors = [
@@ -1,5 +1,8 @@
1
1
  from .get_updates_handler import GetUpdatesAsyncDispatcher
2
- from .redis_pubsub_handler import RedisPubSubAsyncDispatcher
2
+ try:
3
+ from .redis_pubsub_handler import RedisPubSubAsyncDispatcher
4
+ except ImportError:
5
+ pass
3
6
 
4
7
  __all__ = [
5
8
  'GetUpdatesAsyncDispatcher',
@@ -17,7 +17,7 @@ class GetUpdatesAsyncDispatcher:
17
17
  update_handler: UpdateHandler
18
18
  tasks_shutdown_timeout: float
19
19
  tasks: set[asyncio.Task] # prevent gc from collecting tasks before they finish
20
- bot: botapi.api.BotAPI
20
+ bot: 'botapi.api.BotAPI'
21
21
  reconnect_delay: float
22
22
  allowed_updates: list[str]
23
23
  offset: int
@@ -25,7 +25,7 @@ class GetUpdatesAsyncDispatcher:
25
25
  def __init__(
26
26
  self,
27
27
  update_handler: UpdateHandler,
28
- bot: botapi.api.BotAPI,
28
+ bot: 'botapi.api.BotAPI',
29
29
  allowed_updates: list[str], # botapi.enums.UpdateType
30
30
  reconnect_delay: float = 5,
31
31
  shutdown_wait_timeout: float = 3
@@ -11,8 +11,9 @@ try:
11
11
  import redis.asyncio as redis
12
12
  from redis.asyncio.client import PubSub
13
13
  _has_redis = True
14
- except ImportError:
14
+ except ImportError as e:
15
15
  _has_redis = False
16
+ raise e
16
17
 
17
18
  logger = logging.getLogger(__name__)
18
19
 
@@ -1,6 +1,6 @@
1
1
  import enum
2
+ from typing import Union
2
3
 
3
- from . import boilerplate
4
4
 
5
5
  class ChatType(enum.StrEnum):
6
6
  PRIVATE = 'private'
@@ -102,11 +102,9 @@ class ServiceMessage(enum.StrEnum):
102
102
  WEB_APP_DATA = 'web_app_data'
103
103
  SUGGESTED_POST = 'suggested_post_info'
104
104
 
105
- @boilerplate.extend_enum(MediaType, ServiceMessage)
106
- class MessageType(enum.StrEnum):
105
+ class OtherMessageType(enum.StrEnum):
107
106
  '''
108
- The content of this message.
109
- All of these fields should be mutually exclusive.
107
+ The type of this message (that does NOT contain multimedia or service content).
110
108
  '''
111
109
  TEXT = 'text'
112
110
  CHECKLIST = 'checklist'
@@ -118,6 +116,18 @@ class MessageType(enum.StrEnum):
118
116
  LOCATION = 'location'
119
117
  CONTACT = 'contact'
120
118
 
119
+ MessageType = Union[
120
+ MediaType,
121
+ ServiceMessage,
122
+ OtherMessageType
123
+ ]
124
+ '''
125
+ The type of the **actual** message content.
126
+
127
+ All of the fields are mutually exclusive, since a message
128
+ can only be of one 'type' at a time.
129
+ '''
130
+
121
131
  class ChatMemberStatus(enum.StrEnum):
122
132
  '''
123
133
  Statuses of a chat member.
@@ -1,20 +0,0 @@
1
- import enum
2
-
3
- from typing import TypeVar, Callable
4
-
5
- # Enums
6
- E = TypeVar('E', bound=enum.Enum)
7
-
8
- def extend_enum(*sources: type[E]) -> Callable[..., type[E]]:
9
- '''
10
- Decorator that extends an Enum class with members
11
- from one or more source Enum classes.
12
- '''
13
- def decorator(target: type[E]) -> type[E]:
14
- for source in sources:
15
- for member in source:
16
- if member.name not in target.__members__:
17
- target._member_map_[member.name] = member
18
- return target
19
- return decorator
20
-
File without changes
File without changes
File without changes
File without changes