mirror of
https://github.com/Rongronggg9/SlashBot.git
synced 2025-02-11 19:03:29 +08:00
auto delete @username
This commit is contained in:
parent
49810eb5d9
commit
39d768b9d5
@ -3,7 +3,7 @@ import re
|
||||
from telegram.ext import Updater, MessageHandler, filters
|
||||
|
||||
Filters = filters.Filters
|
||||
parser = re.compile(r'^\/(\S+)( *)(\S*)$')
|
||||
parser = re.compile(r'^\/(\S+)([ ]*)(\S*)(.*)$')
|
||||
|
||||
# Docker env
|
||||
if os.environ.get('TOKEN') and os.environ['TOKEN'] != 'X':
|
||||
@ -21,7 +21,7 @@ def mention(user):
|
||||
|
||||
|
||||
def get_text(mention_from, mention_rpl, command):
|
||||
parsed = parser.search(command).groups()
|
||||
parsed = [delUsername.sub('', p) for p in parser.search(command).groups()]
|
||||
if parsed[2]:
|
||||
return f"{mention_from} {parsed[0]} {mention_rpl} {parsed[2]}!"
|
||||
else:
|
||||
@ -47,6 +47,7 @@ def reply(update, context):
|
||||
|
||||
|
||||
updater = Updater(token=Token, use_context=True)
|
||||
delUsername = re.compile('@' + updater.bot.username, re.I)
|
||||
dp = updater.dispatcher
|
||||
dp.add_handler(MessageHandler(Filters.regex(parser), reply))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user