5
""" command aliases """
7
__copyright__ = 'this file is in the public domain'
9
from gozerbot.datadir import datadir
10
from gozerbot.persist import Persist
11
from gozerbot.generic import lockdec
14
aliases = Persist(datadir + os.sep + 'aliases') # aliases
18
aliaslock = thread.allocate_lock()
19
locked = lockdec(aliaslock)
21
def aliasreverse(what):
22
""" get the reverse of an alias """
23
for i, j in aliases.data.iteritems():
27
def aliascheck(ievent):
28
""" check if alias is available """
30
cmnd = ievent.txt.split()[0]
31
alias = aliases.data[cmnd]
32
ievent.txt = ievent.txt.replace(cmnd, alias, 1)
35
except (IndexError, KeyError):
40
""" save the aliases data """
44
def aliasset(fromm, to):
46
aliases.data[fromm] = to
50
""" delete an alias """
52
del aliases.data[fromm]
59
""" retrieve an alias """
60
if aliases.data.has_key(fromm):
61
return aliases.data[fromm]