def init(): global todo global db if not db: db = getmaindb() assert db todo = TodoDb() setalias('t', 'todo') setalias('d', 'todo-done') setalias('tt', 'todo-time')
def init(): global db from tl.db import getmaindb db = getmaindb() setalias('k', 'karma-get') setalias('k-del', 'karma-del') setalias('whyup', 'karma-whyup') setalias('whydown', 'karma-whydown') setalias('good', 'karma-good') setalias('bad', 'karma-bad') setalias('whoup', 'karma-whoup') setalias('whodown', 'karma-whodown') setalias('k-search', 'karma-search') setalias('whatup', 'karma-whatup') setalias('whatdown', 'karma-whatdown')
ievent.done() cmnds.add('admin-makebot', handle_adminmakebot, 'OPER') examples.add('admin-makebot', 'create a bot', 'admin-makebot cmndxmpp xmpp') ## admin-stop command def handle_adminstop(bot, ievent): """ no arguments - stop the bot. """ if bot.ownercheck(ievent.userhost): mainhandler.put(0, globalshutdown) else: ievent.reply("you are not the owner of the bot") ievent.done(silent=True) cmnds.add("admin-stop", handle_adminstop, "OPER") examples.add("admin-stop", "stop the bot.", "stop") setalias("qq", "admin-stop") ## admin-setstatus command def handle_adminsetstatus(bot, event): """ arguments: <status> [<statustxt>] - set the status of the bot (xmpp). """ if bot.type != "sxmpp": event.reply("this command only works on sxmpp bots (for now)") ; return if not event.rest: event.missing("<status> [<show>]") ; return status = event.args[0] try: show = event.args[1] except IndexError: show = "" bot.setstatus(status, show) cmnds.add("admin-setstatus", handle_adminsetstatus, ["STATUS", "OPER"]) examples.add("admin-setstatus", "set status of sxmpp bot", "admin-setstatus available Yooo dudes !")
if userhost: host = userhost.split('@')[-1].lower() if host == get_bothost(bot): ievent.reply('not going to ban myself') ; return bot.sendraw('MODE %s +b *!*@%s' % (ievent.channel, host)) ievent.reply('banned %s' % (host, )) else: ievent.reply('can not get userhost of %s' % ievent.args[0]) cmnds.add('ban-add', handle_ban_add, 'OPER') examples.add('ban-add', 'adds a host to the ban list', 'ban-add *!*@lamers.are.us') ## ban-kickban command def handle_kickban_add(bot, ievent): """ arguments: <nick> [<reason>] - add a kickban. """ if not ievent.args: ievent.missing('<nick> [<reason>]') ; return if bot.cfg.nick and ievent.args[0].lower() == bot.cfg.nick.lower(): ievent.reply('not going to kickban myself') return userhost = getwho(bot, ievent.args[0]) reason = len(ievent.args) > 1 and ' '.join(ievent.args[1:]) or 'Permban requested, bye' if userhost: host = userhost.split('@')[-1].lower() if host == get_bothost(bot): ievent.reply('not going to kickban myself') ; return bot.sendraw('MODE %s +b *!*@%s' % (ievent.channel, host)) bot.sendraw('KICK %s %s :%s' % (ievent.channel, ievent.args[0], reason)) else: ievent.reply('can not get userhost of %s' % ievent.args[0]) cmnds.add('ban-kickban', handle_kickban_add, 'OPER') examples.add('ban-kickban', 'kickbans the given nick', 'ban-kickban Lam0r Get out of here') setalias("kickban", "ban-kickban")
if perms: ievent.reply("%s command needs %s permission" % (cmnd, perms)) else: ievent.reply("can't find perm for %s" % cmnd) cmnds.add('perm', handle_perm, ['USER', 'GUEST']) examples.add('perm', 'show permission of command', 'perm quit') ## version command def handle_version(bot, ievent): """ no arguments - show bot's version. """ from tl.version import getfullversion ievent.reply(getfullversion(str(bot.type).upper())) cmnds.add('version', handle_version, ['USER', 'GUEST']) examples.add('version', 'show version of the bot', 'version') setalias('v', "version") ## whereis command def handle_whereis(bot, ievent): """ arguments: <cmnd> - locate a command. """ try: cmnd = ievent.args[0] except IndexError: ievent.missing('<cmnd>') return cmnds.reloadcheck(bot, ievent, cmnd) plugin = cmnds.whereis(cmnd) if plugin: ievent.reply("%s command is in: %s" % (cmnd, plugin)) else: ievent.reply("can't find " + cmnd) cmnds.add('whereis', handle_whereis, ['USER', 'GUEST'])
def init(): global db from tl.db import getmaindb db = getmaindb() setalias('aq', 'quote-add') setalias('wq', 'quote-who') setalias('dq', 'quote-del') setalias('lq', 'quote-last') setalias('2q', 'quote-2') setalias('iq', 'quote-id') setalias('q', 'quote') setalias('sq', 'quote-search') setalias('cq', 'quote-count') setalias('q-good', 'quote-good') setalias('q-bad', 'quote-bad')
from tl.lib.config import getmainconfig from tl.lib.aliases import setalias allowset = ["timesleep", "dbenable"] def handle_cfgset(bot, event): if len(event.args) != 3: event.missing("<configname> <variable> <value>") ; return name, var, value = event.args if not var in allowset: event.reply("setting %s is not allowed" % var) ; return if name == "main": if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return mcfg = getmainconfig() try: mcfg[var] = int(value) except ValueError: mcfg[var] = value mcfg.save() event.done() else: event.reply('we current only support editing the "main" config.') ; return cmnds.add("cfg-set", handle_cfgset, ["OPER", "USER"]) setalias("mcfg-set", "cfg-set main") def handle_cfg(bot, event): if len(event.args) != 1: event.missing("<configname>") ; return name = event.args[0] if name == "main": if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return event.reply(getmainconfig().fordisplay()) cmnds.add("cfg", handle_cfg, ["OPER", "USER"]) setalias("mcfg", "cfg main")