forked from kate/uniborg
Add snipl and snipd commands
This commit is contained in:
parent
882fcfe471
commit
ec50e689b4
|
@ -20,10 +20,11 @@ def remove_snip(name):
|
||||||
os.remove(text)
|
os.remove(text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('failed to remove', snip, 'due to', e, file=sys.stderr)
|
print('failed to remove', snip, 'due to', e, file=sys.stderr)
|
||||||
|
del snips[name]
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(pattern=r'.snip (\w+)'))
|
@borg.on(events.NewMessage(pattern=r'.snip (\w+)'))
|
||||||
async def on_message(event):
|
async def on_snip(event):
|
||||||
msg = await event.reply_message
|
msg = await event.reply_message
|
||||||
name = event.pattern_match.group(1)
|
name = event.pattern_match.group(1)
|
||||||
if msg:
|
if msg:
|
||||||
|
@ -43,3 +44,15 @@ async def on_message(event):
|
||||||
await borg.send_message(await event.input_chat, text)
|
await borg.send_message(await event.input_chat, text)
|
||||||
|
|
||||||
await event.delete()
|
await event.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@borg.on(events.NewMessage(pattern=r'.snipl'))
|
||||||
|
async def on_snip_list(event):
|
||||||
|
await event.respond('available snips: ' + ', '.join(snips.keys()))
|
||||||
|
await event.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@borg.on(events.NewMessage(pattern=r'.snipd (\w+)'))
|
||||||
|
async def on_snip_delete(event):
|
||||||
|
remove_snip(event.pattern_match.group(1))
|
||||||
|
await event.delete()
|
||||||
|
|
Loading…
Reference in New Issue