From 15d8b312f4df9d84eb1484fd03b0407048a18bc6 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Wed, 13 Jun 2018 21:31:48 +0300 Subject: [PATCH 1/2] Rename re(gex) plugin to sed --- stdplugins/{re.py => sed.py} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename stdplugins/{re.py => sed.py} (94%) diff --git a/stdplugins/re.py b/stdplugins/sed.py similarity index 94% rename from stdplugins/re.py rename to stdplugins/sed.py index df3e908..fe518a4 100644 --- a/stdplugins/re.py +++ b/stdplugins/sed.py @@ -5,7 +5,7 @@ import regex from telethon import events, utils from telethon.tl import types, functions -HEADER = "[[regex]]\n" +HEADER = "[[sed]]\n" KNOWN_RE_BOTS = re.compile( r'(regex|moku|BananaButler_|rgx|l4mR)bot', flags=re.IGNORECASE @@ -62,7 +62,7 @@ def doit(chat_id, match, original): return None, None -async def group_has_regex(group): +async def group_has_sedbot(group): if isinstance(group, types.InputPeerChannel): full = await borg(functions.channels.GetFullChannelRequest(group)) elif isinstance(group, types.InputPeerChat): @@ -83,7 +83,7 @@ async def on_message(event): async def on_regex(event): if event.forward: return - if not event.is_private and await group_has_regex(await event.input_chat): + if not event.is_private and await group_has_sedbot(await event.input_chat): return chat_id = utils.get_peer_id(await event.input_chat) From def5d5d6515ce6df0344fde4e11c8ada8fd89a06 Mon Sep 17 00:00:00 2001 From: EyeZiS Date: Thu, 14 Jun 2018 20:03:14 +0200 Subject: [PATCH 2/2] Use literal . in regex for commands --- stdplugins/aesthetics.py | 4 ++-- stdplugins/snip.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stdplugins/aesthetics.py b/stdplugins/aesthetics.py index 462fc32..0495c5d 100644 --- a/stdplugins/aesthetics.py +++ b/stdplugins/aesthetics.py @@ -17,8 +17,8 @@ def aesthetify(string): yield chr(c) -@borg.on(events.NewMessage(pattern=r'.ae\s+(.+)', outgoing=True)) -@borg.on(events.MessageEdited(pattern=r'.ae\s+(.+)', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.ae\s+(.+)', outgoing=True)) +@borg.on(events.MessageEdited(pattern=r'\.ae\s+(.+)', outgoing=True)) async def _(event): text = event.pattern_match.group(1) text = "".join(aesthetify(text)) diff --git a/stdplugins/snip.py b/stdplugins/snip.py index 9668b15..5ec01a9 100644 --- a/stdplugins/snip.py +++ b/stdplugins/snip.py @@ -14,7 +14,7 @@ TYPE_DOCUMENT = 2 snips = storage.snips or {} -@borg.on(events.NewMessage(pattern=r'.snip (\S+)', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.snip (\S+)', outgoing=True)) async def on_snip(event): name = event.pattern_match.group(1) if name not in snips: @@ -35,7 +35,7 @@ async def on_snip(event): await event.delete() -@borg.on(events.NewMessage(pattern=r'.snips (\S+)', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.snips (\S+)', outgoing=True)) async def on_snip_save(event): name = event.pattern_match.group(1) msg = await event.reply_message @@ -60,20 +60,20 @@ async def on_snip_save(event): await event.delete() -@borg.on(events.NewMessage(pattern=r'.snipl', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.snipl', outgoing=True)) async def on_snip_list(event): await event.respond('available snips: ' + ', '.join(snips.keys())) await event.delete() -@borg.on(events.NewMessage(pattern=r'.snipd (\S+)', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.snipd (\S+)', outgoing=True)) async def on_snip_delete(event): snips.pop(event.pattern_match.group(1), None) storage.snips = snips await event.delete() -@borg.on(events.NewMessage(pattern=r'.snipr (\S+)\s+(\S+)', outgoing=True)) +@borg.on(events.NewMessage(pattern=r'\.snipr (\S+)\s+(\S+)', outgoing=True)) async def on_snip_rename(event): snip = snips.pop(event.pattern_match.group(1), None) if snip: