Use literal . in regex for commands

This commit is contained in:
EyeZiS 2018-06-14 20:03:14 +02:00
parent 15d8b312f4
commit def5d5d651
Signed by untrusted user: kate
GPG Key ID: F17AECB58C3A3096
2 changed files with 7 additions and 7 deletions

View File

@ -17,8 +17,8 @@ def aesthetify(string):
yield chr(c) yield chr(c)
@borg.on(events.NewMessage(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)) @borg.on(events.MessageEdited(pattern=r'\.ae\s+(.+)', outgoing=True))
async def _(event): async def _(event):
text = event.pattern_match.group(1) text = event.pattern_match.group(1)
text = "".join(aesthetify(text)) text = "".join(aesthetify(text))

View File

@ -14,7 +14,7 @@ TYPE_DOCUMENT = 2
snips = storage.snips or {} 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): async def on_snip(event):
name = event.pattern_match.group(1) name = event.pattern_match.group(1)
if name not in snips: if name not in snips:
@ -35,7 +35,7 @@ async def on_snip(event):
await event.delete() 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): async def on_snip_save(event):
name = event.pattern_match.group(1) name = event.pattern_match.group(1)
msg = await event.reply_message msg = await event.reply_message
@ -60,20 +60,20 @@ async def on_snip_save(event):
await event.delete() 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): async def on_snip_list(event):
await event.respond('available snips: ' + ', '.join(snips.keys())) await event.respond('available snips: ' + ', '.join(snips.keys()))
await event.delete() 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): async def on_snip_delete(event):
snips.pop(event.pattern_match.group(1), None) snips.pop(event.pattern_match.group(1), None)
storage.snips = snips storage.snips = snips
await event.delete() 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): async def on_snip_rename(event):
snip = snips.pop(event.pattern_match.group(1), None) snip = snips.pop(event.pattern_match.group(1), None)
if snip: if snip: