Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit d16a1be

Browse files
Update for Pyrogram v1.0
1 parent 7c8e7b1 commit d16a1be

File tree

8 files changed

+95
-94
lines changed

8 files changed

+95
-94
lines changed

‎assistant/assistant.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
import time
2424
from datetime import datetime
2525

26-
from pyrogram import Client, Message
26+
from pyrogram import Client
2727
from pyrogram import __version__
28-
from pyrogram.api.all import layer
28+
from pyrogram.raw.all import layer
29+
from pyrogram.types import Message
2930

3031

3132
class Assistant(Client):

‎assistant/plugins/commands.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
import aiohttp
2828
from num2words import num2words
29-
from pyrogram import (CallbackQuery, ChatPermissions, Emoji, Filters,
30-
InlineKeyboardButton, InlineKeyboardMarkup, Message)
29+
from pyrogram import filters, emoji
30+
frompyrogram.typesimportCallbackQuery, ChatPermissions, InlineKeyboardButton, InlineKeyboardMarkup, Message
3131

3232
from ..assistant import Assistant
3333
from ..utils import docs
3434

35-
command = partial(Filters.command, prefixes="#")
35+
command = partial(filters.command, prefixes="#")
3636

3737

3838
async def reply_and_delete(message: Message, text: str):
@@ -237,9 +237,9 @@ async def rules(_, message: Message):
237237

238238

239239
@Assistant.on_message(
240-
Filters.via_bot
241-
& Filters.regex(r"^Pyrogram Rules\n")
242-
& ~Filters.regex(r"^Pyrogram Rules[\s\S]+notice\.$")
240+
filters.via_bot
241+
& filters.regex(r"^Pyrogram Rules\n")
242+
& ~filters.regex(r"^Pyrogram Rules[\s\S]+notice\.$")
243243
) # I know this is ugly, but this way we don't filter the full ruleset lol
244244
async def repost_rules(_, message: Message):
245245
code = message.entities[-1]
@@ -258,15 +258,15 @@ async def repost_rules(_, message: Message):
258258
**Pyrogram group chats**
259259
260260
__Main groups__
261-
[{Emoji.GLOBE_WITH_MERIDIANS} International (English)](t.me/PyrogramChat)
262-
[{Emoji.SPEECH_BALLOON} Offtopic group](t.me/PyrogramLounge)
261+
[{emoji.GLOBE_WITH_MERIDIANS} International (English)](t.me/PyrogramChat)
262+
[{emoji.SPEECH_BALLOON} Offtopic group](t.me/PyrogramLounge)
263263
264264
__Other groups__
265-
[{Emoji.ITALY} Italian](t.me/joinchat/AWDQ8lDPvwpWu3UH4Bx9Uw)
266-
[{Emoji.IRAN} Farsi](t.me/PyrogramIR)
267-
[{Emoji.BRAZIL} Portuguese](t.me/PyrogramBR)
268-
[{Emoji.INDONESIA} Indonesian](t.me/PyrogramID)
269-
[{Emoji.RUSSIA} Russian](t.me/RuPyrogram)
265+
[{emoji.FLAG_ITALY} Italian](t.me/joinchat/AWDQ8lDPvwpWu3UH4Bx9Uw)
266+
[{emoji.FLAG_IRAN} Farsi](t.me/PyrogramIR)
267+
[{emoji.FLAG_BRAZIL} Portuguese](t.me/PyrogramBR)
268+
[{emoji.FLAG_INDONESIA} Indonesian](t.me/PyrogramID)
269+
[{emoji.FLAG_RUSSIA} Russian](t.me/RuPyrogram)
270270
271271
__If you want to host and maintain a group dedicated to your language, let us know!__
272272
"""
@@ -459,8 +459,8 @@ async def ban(bot: Assistant, message: Message):
459459

460460
################################
461461

462-
LOCKED = f"{Emoji.LOCKED} Chat has been locked. Send #unlock to unlock."
463-
UNLOCKED = f"{Emoji.UNLOCKED} Chat has been unlocked."
462+
LOCKED = f"{emoji.LOCKED} Chat has been locked. Send #unlock to unlock."
463+
UNLOCKED = f"{emoji.UNLOCKED} Chat has been unlocked."
464464

465465
PERMISSIONS = {-1001387666944: ChatPermissions(can_send_messages=True, can_send_media_messages=True)} # Inn
466466
PERMISSIONS.update(
@@ -513,7 +513,7 @@ async def evil(_, message: Message):
513513
################################
514514

515515
# Pattern: https://regex101.com/r/6xdeRf/3
516-
@Assistant.on_callback_query(Filters.regex(r"^(?P<action>remove|unban)\.(?P<uid>\d+)"))
516+
@Assistant.on_callback_query(filters.regex(r"^(?P<action>remove|unban)\.(?P<uid>\d+)"))
517517
async def cb_query(bot: Assistant, query: CallbackQuery):
518518
match = query.matches[0]
519519
action = match.group("action")

‎assistant/plugins/inline.py‎

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
from pyrogram import (
24-
Emoji, InlineQuery, InlineQueryResultArticle, InlineQueryResultPhoto, InputTextMessageContent, InlineKeyboardButton,
25-
InlineKeyboardMarkup, __version__
26-
)
23+
from pyrogram import emoji, __version__
24+
from pyrogram.types import (InlineQuery, InlineQueryResultArticle, InlineQueryResultPhoto, InputTextMessageContent,
25+
InlineKeyboardButton, InlineKeyboardMarkup)
2726

2827
from ..assistant import Assistant
2928
from ..utils import docs
@@ -47,31 +46,31 @@ async def inline(_, query: InlineQuery):
4746
await query.answer(
4847
results=docs.DEFAULT_RESULTS,
4948
cache_time=CACHE_TIME,
50-
switch_pm_text=f"{Emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Pyrogram Docs",
49+
switch_pm_text=f"{emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Pyrogram Docs",
5150
switch_pm_parameter="start",
5251
)
5352

5453
return
5554

5655
results = []
5756
offset = int(query.offset or 0)
58-
switch_pm_text = f"{Emoji.OPEN_BOOK} Pyrogram Docs"
57+
switch_pm_text = f"{emoji.OPEN_BOOK} Pyrogram Docs"
5958

6059
if string == "!m":
61-
switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Methods ({len(docs.METHODS)})"
60+
switch_pm_text = f"{emoji.CLOSED_BOOK} Pyrogram Methods ({len(docs.METHODS)})"
6261

6362
if offset == 0:
6463
results.append(
6564
InlineQueryResultArticle(
6665
title="Methods",
6766
description="Pyrogram Methods online documentation page",
6867
input_message_content=InputTextMessageContent(
69-
f"{Emoji.FIRE} **Pyrogram Methods**\n\n"
68+
f"{emoji.FIRE} **Pyrogram Methods**\n\n"
7069
f"`This page contains all available high-level Methods existing in Pyrogram v{VERSION}.`"
7170
),
7271
reply_markup=InlineKeyboardMarkup([[
7372
InlineKeyboardButton(
74-
f"{Emoji.OPEN_BOOK} Online docs",
73+
f"{emoji.OPEN_BOOK} Online docs",
7574
url="https://docs.pyrogram.org/api/methods"
7675
)
7776
]]),
@@ -82,20 +81,20 @@ async def inline(_, query: InlineQuery):
8281
for i in docs.METHODS[offset: offset + NEXT_OFFSET]:
8382
results.append(i[1])
8483
elif string == "!t":
85-
switch_pm_text = f"{Emoji.GREEN_BOOK} Pyrogram Types ({len(docs.TYPES)})"
84+
switch_pm_text = f"{emoji.GREEN_BOOK} Pyrogram Types ({len(docs.TYPES)})"
8685

8786
if offset == 0:
8887
results.append(
8988
InlineQueryResultArticle(
9089
title="Types",
9190
description="Pyrogram Types online documentation page",
9291
input_message_content=InputTextMessageContent(
93-
f"{Emoji.FIRE} **Pyrogram Types**\n\n"
92+
f"{emoji.FIRE} **Pyrogram Types**\n\n"
9493
f"`This page contains all available high-level Types existing in Pyrogram v{VERSION}.`"
9594
),
9695
reply_markup=InlineKeyboardMarkup([[
9796
InlineKeyboardButton(
98-
f"{Emoji.OPEN_BOOK} Online docs",
97+
f"{emoji.OPEN_BOOK} Online docs",
9998
url="https://docs.pyrogram.org/api/types"
10099
)
101100
]]),
@@ -106,20 +105,20 @@ async def inline(_, query: InlineQuery):
106105
for i in docs.TYPES[offset: offset + NEXT_OFFSET]:
107106
results.append(i[1])
108107
elif string == "!b":
109-
switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Bound Methods ({len(docs.BOUND_METHODS)})"
108+
switch_pm_text = f"{emoji.CLOSED_BOOK} Pyrogram Bound Methods ({len(docs.BOUND_METHODS)})"
110109

111110
if offset == 0:
112111
results.append(
113112
InlineQueryResultArticle(
114113
title="Types",
115114
description="Pyrogram Bound Methods online documentation page",
116115
input_message_content=InputTextMessageContent(
117-
f"{Emoji.FIRE} **Pyrogram Bound Methods**\n\n"
116+
f"{emoji.FIRE} **Pyrogram Bound Methods**\n\n"
118117
f"`This page contains all available bound methods existing in Pyrogram v{VERSION}.`"
119118
),
120119
reply_markup=InlineKeyboardMarkup([[
121120
InlineKeyboardButton(
122-
f"{Emoji.OPEN_BOOK} Online docs",
121+
f"{emoji.OPEN_BOOK} Online docs",
123122
url="https://docs.pyrogram.org/api/bound-methods"
124123
)]]
125124
),
@@ -130,20 +129,20 @@ async def inline(_, query: InlineQuery):
130129
for i in docs.BOUND_METHODS[offset: offset + NEXT_OFFSET]:
131130
results.append(i[1])
132131
elif string == "!d":
133-
switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Decorators ({len(docs.DECORATORS)})"
132+
switch_pm_text = f"{emoji.CLOSED_BOOK} Pyrogram Decorators ({len(docs.DECORATORS)})"
134133

135134
if offset == 0:
136135
results.append(
137136
InlineQueryResultArticle(
138137
title="Decorators",
139138
description="Pyrogram Decorators online documentation page",
140139
input_message_content=InputTextMessageContent(
141-
f"{Emoji.FIRE} **Pyrogram Decorators**\n\n"
140+
f"{emoji.FIRE} **Pyrogram Decorators**\n\n"
142141
f"`This page contains all available decorators existing in Pyrogram v{VERSION}.`"
143142
),
144143
reply_markup=InlineKeyboardMarkup([[
145144
InlineKeyboardButton(
146-
f"{Emoji.OPEN_BOOK} Online docs",
145+
f"{emoji.OPEN_BOOK} Online docs",
147146
url="https://docs.pyrogram.org/api/decorators"
148147
)]]
149148
),
@@ -154,20 +153,20 @@ async def inline(_, query: InlineQuery):
154153
for i in docs.DECORATORS[offset: offset + NEXT_OFFSET]:
155154
results.append(i[1])
156155
elif string == "!f":
157-
switch_pm_text = f"{Emoji.CONTROL_KNOBS} Pyrogram Filters ({len(docs.FILTERS)})"
156+
switch_pm_text = f"{emoji.CONTROL_KNOBS} Pyrogram Filters ({len(docs.FILTERS)})"
158157

159158
if offset == 0:
160159
results.append(
161160
InlineQueryResultArticle(
162161
title="Filters",
163162
description="Pyrogram Filters online documentation page",
164163
input_message_content=InputTextMessageContent(
165-
f"{Emoji.FIRE} **Pyrogram Filters**\n\n"
164+
f"{emoji.FIRE} **Pyrogram Filters**\n\n"
166165
f"`This page contains all library-defined Filters available in Pyrogram v{VERSION}.`"
167166
),
168167
reply_markup=InlineKeyboardMarkup([[
169168
InlineKeyboardButton(
170-
f"{Emoji.OPEN_BOOK} Online docs",
169+
f"{emoji.OPEN_BOOK} Online docs",
171170
url="https://docs.pyrogram.org/api/filters"
172171
)
173172
]]),
@@ -178,25 +177,25 @@ async def inline(_, query: InlineQuery):
178177
for i in docs.FILTERS[offset: offset + NEXT_OFFSET]:
179178
results.append(i[1])
180179
elif string == "!rm":
181-
switch_pm_text = f"{Emoji.BLUE_BOOK} Raw Methods ({len(docs.RAW_METHODS)})"
180+
switch_pm_text = f"{emoji.BLUE_BOOK} Raw Methods ({len(docs.RAW_METHODS)})"
182181

183182
if offset == 0:
184183
results.append(
185184
InlineQueryResultArticle(
186185
title="Raw Methods",
187186
description="Pyrogram Raw Methods online documentation page",
188187
input_message_content=InputTextMessageContent(
189-
f"{Emoji.FIRE} **Pyrogram Raw Methods**\n\n"
188+
f"{emoji.FIRE} **Pyrogram Raw Methods**\n\n"
190189
f"`This page contains all available Raw Methods existing in the Telegram Schema, Layer `"
191190
f"`{docs.layer}.`"
192191
),
193192
reply_markup=InlineKeyboardMarkup([[
194193
InlineKeyboardButton(
195-
f"{Emoji.OPEN_BOOK} Online docs",
194+
f"{emoji.OPEN_BOOK} Online docs",
196195
url="https://docs.pyrogram.org/telegram/functions"
197196
),
198197
InlineKeyboardButton(
199-
f"{Emoji.SCROLL} TL Schema",
198+
f"{emoji.SCROLL} TL Schema",
200199
url="https://github.com/pyrogram/pyrogram/blob/develop/compiler/api/source/main_api.tl"
201200
),
202201
]]),
@@ -207,25 +206,25 @@ async def inline(_, query: InlineQuery):
207206
for i in docs.RAW_METHODS[offset: offset + NEXT_OFFSET]:
208207
results.append(i[1])
209208
elif string == "!rt":
210-
switch_pm_text = f"{Emoji.ORANGE_BOOK} Raw Types ({len(docs.RAW_TYPES)})"
209+
switch_pm_text = f"{emoji.ORANGE_BOOK} Raw Types ({len(docs.RAW_TYPES)})"
211210

212211
if offset == 0:
213212
results.append(
214213
InlineQueryResultArticle(
215214
title="Raw Types",
216215
description="Pyrogram Raw Types online documentation page",
217216
input_message_content=InputTextMessageContent(
218-
f"{Emoji.FIRE} **Pyrogram Raw Types**\n\n"
217+
f"{emoji.FIRE} **Pyrogram Raw Types**\n\n"
219218
f"`This page contains all available Raw Types existing in the Telegram Schema, Layer "
220219
f"{docs.layer}.`"
221220
),
222221
reply_markup=InlineKeyboardMarkup([[
223222
InlineKeyboardButton(
224-
f"{Emoji.OPEN_BOOK} Online docs",
223+
f"{emoji.OPEN_BOOK} Online docs",
225224
url="https://docs.pyrogram.org/telegram/types"
226225
),
227226
InlineKeyboardButton(
228-
f"{Emoji.SCROLL} TL Schema",
227+
f"{emoji.SCROLL} TL Schema",
229228
url="https://github.com/pyrogram/pyrogram/blob/develop/compiler/api/source/main_api.tl",
230229
),
231230
]]),
@@ -236,7 +235,7 @@ async def inline(_, query: InlineQuery):
236235
for i in docs.RAW_TYPES[offset: offset + NEXT_OFFSET]:
237236
results.append(i[1])
238237
elif string == "rules":
239-
switch_pm_text = f"{Emoji.SCROLL} Chat Rules"
238+
switch_pm_text = f"{emoji.SCROLL} Chat Rules"
240239

241240
if offset == 0:
242241
results.append(
@@ -251,7 +250,7 @@ async def inline(_, query: InlineQuery):
251250
for i in docs.RULES[offset: offset + NEXT_OFFSET]:
252251
results.append(i)
253252
elif string == "colin":
254-
switch_pm_text = f"{Emoji.SHARK} Hidden Shark"
253+
switch_pm_text = f"{emoji.SHARK} Hidden Shark"
255254

256255
if offset == 0:
257256
results.append(
@@ -260,8 +259,8 @@ async def inline(_, query: InlineQuery):
260259
# thumb_url="https://i.imgur.com/f32hngs.jpg",
261260
title="You found the secret Sharkception :O",
262261
description="You might not get anything from it, but you can feel proud to have found me!",
263-
caption=f"Hey, I found @ColinShark {Emoji.SHARK}",
264-
# input_message_content=InputTextMessageContent(f"Hey, I found @ColinShark {Emoji.SHARK}"),
262+
caption=f"Hey, I found @ColinShark {emoji.SHARK}",
263+
# input_message_content=InputTextMessageContent(f"Hey, I found @ColinShark {emoji.SHARK}"),
265264
)
266265
)
267266

@@ -291,7 +290,7 @@ async def inline(_, query: InlineQuery):
291290
await query.answer(
292291
results=[],
293292
cache_time=CACHE_TIME,
294-
switch_pm_text=f"{Emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Raw Docs",
293+
switch_pm_text=f"{emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Raw Docs",
295294
switch_pm_parameter="start",
296295
)
297296

@@ -326,7 +325,7 @@ async def inline(_, query: InlineQuery):
326325

327326
if results:
328327
count = len(results)
329-
switch_pm_text = f"{Emoji.OPEN_BOOK} {count} Result{'s' if count > 1 else ''} for \"{string}\""
328+
switch_pm_text = f"{emoji.OPEN_BOOK} {count} Result{'s' if count > 1 else ''} for \"{string}\""
330329

331330
await query.answer(
332331
results=results[:50],
@@ -338,6 +337,6 @@ async def inline(_, query: InlineQuery):
338337
await query.answer(
339338
results=[],
340339
cache_time=CACHE_TIME,
341-
switch_pm_text=f'{Emoji.CROSS_MARK} No results for "{string}"',
340+
switch_pm_text=f'{emoji.CROSS_MARK} No results for "{string}"',
342341
switch_pm_parameter="okay",
343342
)

‎assistant/plugins/private.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
from pyrogram import Filters, Message, InlineKeyboardMarkup, InlineKeyboardButton, Emoji
23+
from pyrogram import filters, emoji
24+
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
2425

2526
from ..assistant import Assistant
2627
from ..utils import docs
2728

2829

29-
@Assistant.on_message(Filters.private)
30+
@Assistant.on_message(filters.private)
3031
async def go(_, message: Message):
3132
await message.reply(
3233
docs.HELP,
3334
disable_web_page_preview=True,
3435
parse_mode="markdown",
3536
reply_markup=InlineKeyboardMarkup([[
3637
InlineKeyboardButton(
37-
f"{Emoji.CARD_INDEX_DIVIDERS} Source Code",
38+
f"{emoji.CARD_INDEX_DIVIDERS} Source Code",
3839
url="https://github.com/pyrogram/assistant"
3940
),
4041
InlineKeyboardButton(
41-
f"{Emoji.FIRE} Go!",
42+
f"{emoji.FIRE} Go!",
4243
switch_inline_query=""
4344
)
4445
]])

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /