/usr/share/pyshared/gplugs/links.py is in gozerbot 0.99.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # plugs/links.py
#
#
""" link <item> to <otheritem> """
__copyright__ = 'this file is in the public domain'
from gozerbot.commands import cmnds
from gozerbot.redispatcher import rebefore
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.persist.pdol import Pdol
from gozerbot.datadir import datadir
import os
plughelp.add('links', 'alias items to other items .. this is only used in \
karma for now')
links = Pdol(datadir + os.sep + 'links')
def handle_linksadd(bot, ievent):
""" links-add <item> = <otheritem> """
try:
(item, otheritem) = ievent.groups
except ValueError:
ievent.missing('<item> = <otheritem>')
return
links.add(item, otheritem)
links.save()
ievent.reply('%s link added' % otheritem)
rebefore.add(5, 'links-add (.*?) = (.*)', handle_linksadd, 'USER')
examples.add('links-add', 'links-add <from> = <to> .. add a link', \
'links-add mekker = miep bla')
def handle_linksdel(bot, ievent):
""" links-del <item> = <otheritem> """
try:
(item, linkto) = ievent.groups
except ValueError:
ievent.missing('<item> = <link>')
return
itemlist = links[item]
if not itemlist:
ievent.reply('no links available for %s' % item)
return
for i in range(len(itemlist)-1, -1, -1):
if itemlist[i] == linkto:
del itemlist[i]
links.save()
ievent.reply('%s deleted' % linkto)
return
rebefore.add(5, 'links-del (.*?) = (.*)', handle_linksdel, ['LINKS', 'OPER'])
examples.add('links-del', 'links-del <from> = <to> .. delete a link', \
'links-del mekker = miep bla')
def handle_linkslist(bot, ievent):
""" links-list <item> .. show link of <item> """
if not ievent.rest:
ievent.missing('<item>')
return
result = links[ievent.rest]
if result:
ievent.reply("links for %s: " % ievent.rest, result)
else:
ievent.reply('no links found for %s' % ievent.rest)
cmnds.add('links-list', handle_linkslist, 'USER')
examples.add('links-list', 'links-list <item> .. show link of <item>', \
'links-list mekker')
|