forked from kate/uniborg
Add snip rename method
This commit is contained in:
parent
32acefa991
commit
bdb402e645
|
@ -17,7 +17,7 @@ TYPE_DOCUMENT = 2
|
||||||
snips = storage.snips or {}
|
snips = storage.snips or {}
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(pattern=r'.snip (.+)'))
|
@borg.on(events.NewMessage(pattern=r'.snip (\S+)'))
|
||||||
async def on_snip(event):
|
async def on_snip(event):
|
||||||
name = event.pattern_match.group(1)
|
name = event.pattern_match.group(1)
|
||||||
if name in snips:
|
if name in snips:
|
||||||
|
@ -36,7 +36,7 @@ async def on_snip(event):
|
||||||
await event.delete()
|
await event.delete()
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(pattern=r'.snips (.+)'))
|
@borg.on(events.NewMessage(pattern=r'.snips (\S+)'))
|
||||||
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
|
||||||
|
@ -67,7 +67,17 @@ async def on_snip_list(event):
|
||||||
await event.delete()
|
await event.delete()
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(pattern=r'.snipd (.+)'))
|
@borg.on(events.NewMessage(pattern=r'.snipd (\S+)'))
|
||||||
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)
|
||||||
await event.delete()
|
await event.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@borg.on(events.NewMessage(pattern=r'.snipr (\S+)\s+(\S+)'))
|
||||||
|
async def on_snip_rename(event):
|
||||||
|
snip = snips.pop(event.pattern_match.group(1), None)
|
||||||
|
if snip:
|
||||||
|
snips[event.pattern_match.group(2)] = snip
|
||||||
|
storage.snips = snips
|
||||||
|
|
||||||
|
await event.delete()
|
||||||
|
|
Loading…
Reference in New Issue