from gozerbot.examples import examples from gozerbot.callbacks import callbacks from gozerbot.users import users from gozerbot.plugins import plugins from gozerbot.datadir import datadir from gozerbot.persist.persist import PlugPersist from gozerbot.plughelp import plughelp from gozerbot.tests import tests import time, os plughelp.add('away', "keep notice of who's away") lasttime = [] # use datadir/away as pickle file awaydict = PlugPersist('away.data') # see if data attribute is set otherwise init it if not awaydict.data: awaydict.data = {} if not awaydict.data.has_key('enable'): awaydict.data['enable'] = 0 awaydict.save() def init(): """ init plugin """ if not awaydict.data['enable']: rlog(0, 'away', 'away is disabled') return 1 else: rlog(0, 'away', 'away is enabled')
from gozerbot.commands import cmnds from gozerbot.plughelp import plughelp from gozerbot.persist.persist import PlugPersist from gozerbot.aliases import aliasset from time import sleep, time from random import randint, shuffle plughelp.add('timebomb', 'blow your buddies to smithereens !timebomb <victim>') plughelp.add( 'cut', 'try to defuse a bomb placed with !timebomb by cutting a wire i.e. !cut blue' ) # define plugpersist outside localscope, you only want to initiate it once. bomb = PlugPersist('bomb') bomb.data = [] def timebomb(bot, ievent): # check if we have ops if ievent.channel not in bot.state['opchan']: bot.action( ievent.channel, "bends over and farts in %s's general direction." % ievent.nick) return # check if we are already running a bomb if bomb.data: bot.action(ievent.channel, "points at the bulge in %s's pants." % bomb.data[0]) return
__copyright__ = 'this file is in the public domain' from gozerbot.generic import elapsedstring, getwho, jsonstring from gozerbot.commands import cmnds from gozerbot.callbacks import callbacks, jcallbacks from gozerbot.examples import examples from gozerbot.datadir import datadir from gozerbot.persist.persist import PlugPersist from gozerbot.plughelp import plughelp from gozerbot.aliases import aliases import time, os plughelp.add('idle', 'show how long a user or channel has been idle') idle = PlugPersist('idle.data') if not idle.data: idle.data = {} def shutdown(): idle.save() def preidle(bot, ievent): """ idle precondition aka check if it is not a command """ if ievent.usercmnd: return 0 else: return 1
## UPGRADE PART def upgrade(): convertpickle(datadir + os.sep + 'old' + os.sep + 'pt-projects', \ datadir + os.sep + 'plugs' + os.sep + 'projecttracker' + os.sep + 'pt-projects') convertpickle(datadir + os.sep + 'old' + os.sep + 'pt-contrib', \ datadir + os.sep + 'plugs' + os.sep + 'projecttracker' + os.sep + 'pt-contrib') ## END UPGRADE PART import os projects = PlugPersist('pt-projects') contrib = PlugPersist('pt-contrib') if not projects.data: projects = PlugPersist('pt-projects') if not projects.data: projects.data = {} if not contrib.data: contrib.data = {} def size(): """ return number of projects """ size = 0 for userprojects in projects.data: size += len(userprojects) return size
from gozerbot.examples import examples from gozerbot.persist.persist import PlugPersist from gozerbot.plughelp import plughelp import random, os plughelp.add('botsnack', 'give the bot a snack') ## UPGRADE PART def upgrade(): convertpickle(datadir + os.sep + 'old' + os.sep + 'botsnacklist', \ datadir + os.sep + "plugs" + os.sep + "botsnack" + os.sep + 'botsnacklist') ## END UPGRADE PART bsl = PlugPersist('botsnacklist') if not bsl.data: bsl = PlugPersist('botsnacklist') if not bsl.data: bsl.data = [] def handle_botsnack(bot, ievent): """ botsnack .. give botsnack reply """ if bsl.data: result = random.choice(bsl.data) result = result.replace('<nick>', ievent.nick) result = result.replace('<host>', ievent.userhost) ievent.reply(result) else: ievent.reply('smikkel ;]')
plughelp.add( 'event', 'manage events and who is joining them .. can paste \ events to topic') # UPGRADE PART def upgrade(): convertpickle(datadir + os.sep + 'old' + os.sep + 'event', datadir + os.sep + 'plugs' + \ os.sep + 'event' + os.sep + 'event') ## END UPGRADE PART events = PlugPersist('event') if not events.data: events = PlugPersist('event') if not events.data: events.data = {} if not events.data.has_key('eventdict'): events.data['eventdict'] = {} def handle_eventadd(bot, ievent): """ event-add <description> .. add event """ if not ievent.rest: ievent.missing('<descr>') return event = {}
TOKEN = Marker() TOKEN_BEGIN = BeginMarker() TOKEN_END = EndMarker() TOKEN_NICK = NickMarker() # Order-k, use predictate [-k:] = [word,word,] # if ORDER_K==1: { ('eggs'):['with','spam',], 'with': ['bacon','green',] } # if ORDER_K==2: { ('eat','eggs'):['with',TOKEN,), ('eggs','with'): ['bacon',] } # ... # Logical setting is often 2 or 3 ORDER_K = 2 # Maximum generation cycles MAXGEN = 500 markovlearn = PlugPersist('markovlearn', []) markovwords = {} markovwordi = [] markovchains = {} cfg.define('loud', 1) def init(): """ init plugin """ # check if enabled if not cfg.get('enable'): return 1 # if so register callbacks callbacks.add("PRIVMSG", cb_markovtalk, cb_markovtalk_test, threaded=True) callbacks.add('JOIN', cb_markovjoin, threaded=True)