Movatterモバイル変換


[0]ホーム

URL:


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

Commit8261fdb

Browse files
bqbackBibo-Joshi
andauthored
Automatically Trigger/compat TagHint by Regex (#131)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
1 parentef12e2c commit8261fdb

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

‎components/callbacks.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,3 +507,18 @@ async def command_token_warning(update: Update, context: ContextTypes.DEFAULT_TY
507507

508508
ifmessage.reply_to_message:
509509
await_token_warning(message.reply_to_message,context)
510+
511+
512+
asyncdefcompat_warning(update:Update,_:ContextTypes.DEFAULT_TYPE)->None:
513+
"""When someone posts an error message indicative of a compatibility issue:
514+
Reply with the /compat taghint
515+
"""
516+
message=cast(Message,update.effective_message)
517+
518+
# Get the compat hint
519+
hint=TAG_HINTS["compat"]
520+
521+
awaitmessage.reply_text(
522+
hint.html_markup(),
523+
reply_markup=hint.inline_keyboard,
524+
)

‎components/const.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,11 @@
230230
"associated with."
231231
)
232232
TOKEN_TEXT="⚠️ You posted a token, go revoke it with @BotFather.\n\n"
233+
234+
COMPAT_ERRORS=re.compile(
235+
r"""
236+
(Updater\._{0,2}init_{0,2}\(\)\ got\ an\ )?
237+
unexpected\ keyword\ argument\ ['"]*(use_context|token|use_controls|dispatcher)['"]*
238+
""",
239+
flags=re.VERBOSE,
240+
)

‎rules_bot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
ban_sender_channels,
2929
buy,
3030
command_token_warning,
31+
compat_warning,
3132
delete_message,
3233
leave_chat,
3334
off_on_topic,
@@ -44,6 +45,7 @@
4445
fromcomponents.constimport (
4546
ALLOWED_CHAT_IDS,
4647
ALLOWED_USERNAMES,
48+
COMPAT_ERRORS,
4749
ERROR_CHANNEL_CHAT_ID,
4850
OFFTOPIC_CHAT_ID,
4951
OFFTOPIC_USERNAME,
@@ -169,6 +171,9 @@ def main() -> None:
169171
# Tag hints - works with regex
170172
application.add_handler(MessageHandler(TagHintFilter(),tag_hint))
171173

174+
# Compat tag hint via regex
175+
application.add_handler(MessageHandler(filters.Regex(COMPAT_ERRORS),compat_warning))
176+
172177
# We need several matches so filters.REGEX is basically useless
173178
# therefore we catch everything and do regex ourselves
174179
application.add_handler(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp