tlgr-cli 2.0.1__py3-none-any.whl

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.
Files changed (192) hide show
  1. tlgr/__init__.py +3 -0
  2. tlgr/__main__.py +6 -0
  3. tlgr/actions/__init__.py +45 -0
  4. tlgr/actions/forward.py +74 -0
  5. tlgr/actions/reply.py +32 -0
  6. tlgr/cli/__init__.py +259 -0
  7. tlgr/cli/confirm.py +55 -0
  8. tlgr/cli/errors.py +84 -0
  9. tlgr/cli/gen.py +690 -0
  10. tlgr/cli/globals.py +273 -0
  11. tlgr/cli/introspect.py +170 -0
  12. tlgr/cli/params.py +189 -0
  13. tlgr/cli/render.py +418 -0
  14. tlgr/core/__init__.py +0 -0
  15. tlgr/core/accounts.py +384 -0
  16. tlgr/core/config.py +358 -0
  17. tlgr/core/custom_tl.py +170 -0
  18. tlgr/core/errors.py +687 -0
  19. tlgr/core/eventtypes.py +1170 -0
  20. tlgr/core/identity.py +127 -0
  21. tlgr/core/launchd.py +122 -0
  22. tlgr/core/logging.py +194 -0
  23. tlgr/core/media.py +134 -0
  24. tlgr/core/output.py +251 -0
  25. tlgr/core/pagination.py +227 -0
  26. tlgr/core/paths.py +360 -0
  27. tlgr/core/peers.py +427 -0
  28. tlgr/core/process.py +138 -0
  29. tlgr/core/signing.py +38 -0
  30. tlgr/core/systemd.py +96 -0
  31. tlgr/core/telethon_compat.py +295 -0
  32. tlgr/core/text.py +211 -0
  33. tlgr/core/timefmt.py +199 -0
  34. tlgr/core/tl.py +98 -0
  35. tlgr/daemon/__init__.py +0 -0
  36. tlgr/daemon/app.py +869 -0
  37. tlgr/daemon/dispatch.py +446 -0
  38. tlgr/daemon/events.py +723 -0
  39. tlgr/daemon/files.py +431 -0
  40. tlgr/daemon/idle.py +119 -0
  41. tlgr/daemon/jobs.py +68 -0
  42. tlgr/daemon/main.py +161 -0
  43. tlgr/daemon/peercred.py +75 -0
  44. tlgr/daemon/policy.py +113 -0
  45. tlgr/daemon/preauth.py +366 -0
  46. tlgr/daemon/ratelimit.py +391 -0
  47. tlgr/daemon/server.py +24 -0
  48. tlgr/daemon/session.py +648 -0
  49. tlgr/daemon/sessions.py +274 -0
  50. tlgr/daemon/singleton.py +114 -0
  51. tlgr/daemon/stream.py +193 -0
  52. tlgr/daemon/transfers.py +219 -0
  53. tlgr/daemon/webhook.py +390 -0
  54. tlgr/data/catalog_index.json +1 -0
  55. tlgr/data/parity_waivers.toml +90 -0
  56. tlgr/filters/__init__.py +42 -0
  57. tlgr/filters/compose.py +121 -0
  58. tlgr/filters/content.py +85 -0
  59. tlgr/filters/context.py +114 -0
  60. tlgr/filters/message.py +161 -0
  61. tlgr/filters/temporal.py +87 -0
  62. tlgr/filters/user.py +36 -0
  63. tlgr/gateway/__init__.py +1 -0
  64. tlgr/gateway/config.py +161 -0
  65. tlgr/gateway/engine.py +215 -0
  66. tlgr/gateway/event.py +22 -0
  67. tlgr/jobs/__init__.py +0 -0
  68. tlgr/jobs/base.py +81 -0
  69. tlgr/jobs/client.py +37 -0
  70. tlgr/models/__init__.py +1220 -0
  71. tlgr/models/admin.py +744 -0
  72. tlgr/models/auth.py +510 -0
  73. tlgr/models/base.py +81 -0
  74. tlgr/models/bot.py +576 -0
  75. tlgr/models/business.py +265 -0
  76. tlgr/models/call.py +586 -0
  77. tlgr/models/config.py +101 -0
  78. tlgr/models/contact.py +481 -0
  79. tlgr/models/daemon.py +336 -0
  80. tlgr/models/dialog.py +626 -0
  81. tlgr/models/envelope.py +68 -0
  82. tlgr/models/error.py +30 -0
  83. tlgr/models/event.py +79 -0
  84. tlgr/models/export.py +66 -0
  85. tlgr/models/gift.py +275 -0
  86. tlgr/models/inline.py +84 -0
  87. tlgr/models/location.py +115 -0
  88. tlgr/models/media.py +507 -0
  89. tlgr/models/message.py +584 -0
  90. tlgr/models/net.py +232 -0
  91. tlgr/models/notify.py +105 -0
  92. tlgr/models/page.py +32 -0
  93. tlgr/models/payment.py +172 -0
  94. tlgr/models/peer.py +400 -0
  95. tlgr/models/poll.py +119 -0
  96. tlgr/models/premium.py +161 -0
  97. tlgr/models/privacy.py +93 -0
  98. tlgr/models/profile.py +217 -0
  99. tlgr/models/reaction.py +160 -0
  100. tlgr/models/resolve.py +175 -0
  101. tlgr/models/settings.py +103 -0
  102. tlgr/models/stars.py +101 -0
  103. tlgr/models/sticker.py +243 -0
  104. tlgr/models/story.py +467 -0
  105. tlgr/models/sync.py +105 -0
  106. tlgr/models/todo.py +36 -0
  107. tlgr/models/webapp.py +89 -0
  108. tlgr/ops/__init__.py +63 -0
  109. tlgr/ops/_admin.py +313 -0
  110. tlgr/ops/_auth.py +599 -0
  111. tlgr/ops/_bots.py +586 -0
  112. tlgr/ops/_calls.py +535 -0
  113. tlgr/ops/_common.py +160 -0
  114. tlgr/ops/_layer.py +46 -0
  115. tlgr/ops/_media.py +592 -0
  116. tlgr/ops/_params.py +212 -0
  117. tlgr/ops/_rights.py +402 -0
  118. tlgr/ops/_send.py +593 -0
  119. tlgr/ops/_serialize.py +667 -0
  120. tlgr/ops/_settings.py +306 -0
  121. tlgr/ops/_spec.py +167 -0
  122. tlgr/ops/_story.py +743 -0
  123. tlgr/ops/account.py +2604 -0
  124. tlgr/ops/agent.py +937 -0
  125. tlgr/ops/auth.py +1282 -0
  126. tlgr/ops/bot.py +4880 -0
  127. tlgr/ops/business.py +1520 -0
  128. tlgr/ops/call.py +1610 -0
  129. tlgr/ops/chat.py +4025 -0
  130. tlgr/ops/chat_admin.py +929 -0
  131. tlgr/ops/chat_extra.py +1061 -0
  132. tlgr/ops/chat_invite.py +716 -0
  133. tlgr/ops/chat_manage.py +1691 -0
  134. tlgr/ops/chat_member.py +1357 -0
  135. tlgr/ops/chat_stats.py +902 -0
  136. tlgr/ops/chat_topic.py +905 -0
  137. tlgr/ops/conference.py +791 -0
  138. tlgr/ops/config.py +1698 -0
  139. tlgr/ops/contact.py +2330 -0
  140. tlgr/ops/daemon.py +1397 -0
  141. tlgr/ops/draft.py +299 -0
  142. tlgr/ops/emoji.py +343 -0
  143. tlgr/ops/events.py +1327 -0
  144. tlgr/ops/export.py +596 -0
  145. tlgr/ops/folder.py +1322 -0
  146. tlgr/ops/gif.py +522 -0
  147. tlgr/ops/gift.py +1546 -0
  148. tlgr/ops/giveaway.py +541 -0
  149. tlgr/ops/inline.py +773 -0
  150. tlgr/ops/job.py +799 -0
  151. tlgr/ops/location.py +917 -0
  152. tlgr/ops/media.py +4495 -0
  153. tlgr/ops/message.py +3769 -0
  154. tlgr/ops/net.py +536 -0
  155. tlgr/ops/notify.py +840 -0
  156. tlgr/ops/passport.py +464 -0
  157. tlgr/ops/payment.py +907 -0
  158. tlgr/ops/poll.py +1078 -0
  159. tlgr/ops/premium.py +488 -0
  160. tlgr/ops/privacy.py +794 -0
  161. tlgr/ops/profile.py +1481 -0
  162. tlgr/ops/proxy.py +750 -0
  163. tlgr/ops/reaction.py +1475 -0
  164. tlgr/ops/resolve.py +1140 -0
  165. tlgr/ops/search.py +521 -0
  166. tlgr/ops/settings.py +1066 -0
  167. tlgr/ops/stars.py +594 -0
  168. tlgr/ops/sticker.py +1602 -0
  169. tlgr/ops/story.py +3216 -0
  170. tlgr/ops/sync.py +788 -0
  171. tlgr/ops/todo.py +514 -0
  172. tlgr/ops/user.py +1406 -0
  173. tlgr/ops/vc.py +2351 -0
  174. tlgr/ops/webapp.py +717 -0
  175. tlgr/ops/webhook.py +418 -0
  176. tlgr/parity.py +386 -0
  177. tlgr/processors/__init__.py +125 -0
  178. tlgr/processors/regex.py +26 -0
  179. tlgr/processors/text.py +56 -0
  180. tlgr/registry.py +519 -0
  181. tlgr/schema.py +173 -0
  182. tlgr/transport/__init__.py +30 -0
  183. tlgr/transport/autostart.py +293 -0
  184. tlgr/transport/client.py +805 -0
  185. tlgr/transport/ndjson.py +44 -0
  186. tlgr/version.py +31 -0
  187. tlgr_cli-2.0.1.dist-info/METADATA +957 -0
  188. tlgr_cli-2.0.1.dist-info/RECORD +192 -0
  189. tlgr_cli-2.0.1.dist-info/WHEEL +5 -0
  190. tlgr_cli-2.0.1.dist-info/entry_points.txt +2 -0
  191. tlgr_cli-2.0.1.dist-info/licenses/LICENSE +21 -0
  192. tlgr_cli-2.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,265 @@
1
+ """Telegram Business: opening hours, location, intro, quick replies, links,
2
+ and the chatbot that may act on the account's behalf.
3
+
4
+ Two of these carry real risk and the models say so out loud.
5
+
6
+ * **`BotRights` is a full enumeration, never a mask.** Connecting a business
7
+ bot hands another program the ability to read, reply, edit the profile and
8
+ move Stars. A right that is absent from the model is a right nobody can
9
+ audit, so every flag of `businessBotRights` is named.
10
+ * **Opening hours are minutes-of-week, and that arithmetic is lossy.**
11
+ `BusinessOpen` keeps the server's raw minute offsets *and* the human
12
+ spelling, because "mon 09:00-18:00" cannot represent an interval that
13
+ crosses Sunday midnight and the server's vector can.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from typing import Any
19
+
20
+ from tlgr.models.base import Model
21
+ from tlgr.models.message import MessageEntity
22
+ from tlgr.models.peer import Peer
23
+
24
+ __all__ = [
25
+ "BotConnection",
26
+ "BotPaused",
27
+ "BotRights",
28
+ "BusinessAway",
29
+ "BusinessGreeting",
30
+ "BusinessIntro",
31
+ "BusinessLocation",
32
+ "BusinessMessage",
33
+ "BusinessOpen",
34
+ "BusinessProfile",
35
+ "BusinessRecipients",
36
+ "BusinessSet",
37
+ "ChatLink",
38
+ "ChatLinkSet",
39
+ "QuickReply",
40
+ "QuickReplyMessage",
41
+ "QuickReplySent",
42
+ "QuickReplySet",
43
+ "StarsTransferQuote",
44
+ "WorkHours",
45
+ ]
46
+
47
+
48
+ class BusinessOpen(Model):
49
+ """One opening interval.
50
+
51
+ `start_minute`/`end_minute` are minutes since Monday 00:00 in the
52
+ business's own timezone, which is what the server stores; `day` and the
53
+ two clock strings are the same interval said the way a human wrote it.
54
+ """
55
+
56
+ start_minute: int
57
+ end_minute: int
58
+ day: str = ""
59
+ open: str = ""
60
+ close: str = ""
61
+
62
+
63
+ class WorkHours(Model):
64
+ timezone_id: str = ""
65
+ weekly_open: list[BusinessOpen] = []
66
+ #: Server-set and never sent back: whether the business is open right now.
67
+ open_now: bool | None = None
68
+
69
+
70
+ class BusinessLocation(Model):
71
+ address: str = ""
72
+ lat: float | None = None
73
+ lon: float | None = None
74
+
75
+
76
+ class BusinessIntro(Model):
77
+ title: str = ""
78
+ description: str = ""
79
+ sticker_id: int | None = None
80
+
81
+
82
+ class BusinessRecipients(Model):
83
+ """Who a greeting/away message or a connected bot applies to."""
84
+
85
+ contacts: bool = False
86
+ non_contacts: bool = False
87
+ existing_chats: bool = False
88
+ new_chats: bool = False
89
+ exclude_selected: bool = False
90
+ users: list[int] = []
91
+ exclude_users: list[int] = []
92
+
93
+
94
+ class BusinessGreeting(Model):
95
+ shortcut_id: int = 0
96
+ shortcut: str | None = None
97
+ no_activity_days: int = 0
98
+ recipients: BusinessRecipients | None = None
99
+ enabled: bool = True
100
+
101
+
102
+ class BusinessAway(Model):
103
+ shortcut_id: int = 0
104
+ shortcut: str | None = None
105
+ #: always | outside-hours | custom
106
+ schedule: str = "always"
107
+ since: str | None = None
108
+ until: str | None = None
109
+ offline_only: bool = False
110
+ recipients: BusinessRecipients | None = None
111
+ enabled: bool = True
112
+
113
+
114
+ class BusinessMessage(Model):
115
+ """`business message set`, whichever of the two it configured.
116
+
117
+ One shape for both, because a caller that just switched a greeting on
118
+ should not have to know that the away message answers with a different
119
+ struct — and the difference between them is two fields, not two ideas.
120
+ """
121
+
122
+ #: greeting | away
123
+ kind: str
124
+ enabled: bool
125
+ shortcut_id: int = 0
126
+ shortcut: str | None = None
127
+ #: away only: always | outside-hours | custom
128
+ schedule: str | None = None
129
+ since: str | None = None
130
+ until: str | None = None
131
+ offline_only: bool = False
132
+ #: greeting only.
133
+ no_activity_days: int | None = None
134
+ recipients: BusinessRecipients | None = None
135
+
136
+
137
+ class BotRights(Model):
138
+ """`businessBotRights`, every flag named. Absent means "not granted"."""
139
+
140
+ reply: bool = False
141
+ read_messages: bool = False
142
+ delete_sent_messages: bool = False
143
+ delete_received_messages: bool = False
144
+ edit_name: bool = False
145
+ edit_bio: bool = False
146
+ edit_username: bool = False
147
+ edit_profile_photo: bool = False
148
+ view_gifts: bool = False
149
+ sell_gifts: bool = False
150
+ change_gift_settings: bool = False
151
+ transfer_and_upgrade_gifts: bool = False
152
+ transfer_stars: bool = False
153
+ manage_stories: bool = False
154
+
155
+
156
+ class BotConnection(Model):
157
+ """A chatbot connected to (or pending on) this account."""
158
+
159
+ bot_id: int = 0
160
+ bot: Peer | None = None
161
+ connection_id: str | None = None
162
+ recipients: BusinessRecipients | None = None
163
+ rights: BotRights | None = None
164
+ paused: bool = False
165
+ #: layer 229: a connection stays inert until the user confirms it.
166
+ confirmed: bool = True
167
+ disabled: bool = False
168
+ deleted: bool = False
169
+ date: str | None = None
170
+ dc_id: int | None = None
171
+
172
+
173
+ class BotPaused(Model):
174
+ chat_id: int
175
+ paused: bool | None = None
176
+ removed: bool = False
177
+ already: bool = False
178
+
179
+
180
+ class ChatLink(Model):
181
+ slug: str = ""
182
+ link: str = ""
183
+ title: str | None = None
184
+ message: str = ""
185
+ entities: list[MessageEntity] = []
186
+ views: int | None = None
187
+
188
+
189
+ class ChatLinkSet(Model):
190
+ slug: str | None = None
191
+ link: str | None = None
192
+ title: str | None = None
193
+ message: str | None = None
194
+ deleted: bool = False
195
+
196
+
197
+ class QuickReplyMessage(Model):
198
+ id: int
199
+ text: str = ""
200
+ entities: list[MessageEntity] = []
201
+ media: str | None = None
202
+ date: str | None = None
203
+
204
+
205
+ class QuickReply(Model):
206
+ shortcut_id: int
207
+ shortcut: str = ""
208
+ count: int = 0
209
+ top_message: int | None = None
210
+ messages: list[QuickReplyMessage] = []
211
+
212
+
213
+ class QuickReplySet(Model):
214
+ shortcut_id: int | None = None
215
+ shortcut: str | None = None
216
+ msg_id: int | None = None
217
+ msg_ids: list[int] = []
218
+ deleted: int = 0
219
+ order: list[int] = []
220
+ already: bool = False
221
+
222
+
223
+ class QuickReplySent(Model):
224
+ chat_id: int
225
+ shortcut_id: int = 0
226
+ message_ids: list[int] = []
227
+
228
+
229
+ class BusinessProfile(Model):
230
+ """`business get`: the whole Business screen in one object."""
231
+
232
+ work_hours: WorkHours | None = None
233
+ open_now: bool | None = None
234
+ location: BusinessLocation | None = None
235
+ greeting: BusinessGreeting | None = None
236
+ away: BusinessAway | None = None
237
+ intro: BusinessIntro | None = None
238
+ sponsored_enabled: bool | None = None
239
+ connected_bots: list[BotConnection] = []
240
+ chat_links: list[ChatLink] = []
241
+ timezones: list[dict[str, Any]] = []
242
+ premium: bool = False
243
+
244
+
245
+ class BusinessSet(Model):
246
+ work_hours: WorkHours | None = None
247
+ location: BusinessLocation | None = None
248
+ intro: BusinessIntro | None = None
249
+ changed: list[str] = []
250
+ already: bool = False
251
+
252
+
253
+ class StarsTransferQuote(Model):
254
+ """What a Stars transfer to a business bot *would* cost.
255
+
256
+ `ok` is false and `reason` says why: tlgr reads the payment form and
257
+ never signs it (see `ops/payment.py`).
258
+ """
259
+
260
+ bot_id: int
261
+ ok: bool
262
+ stars: int = 0
263
+ currency: str = "XTR"
264
+ reason: str = ""
265
+ form_id: int | None = None