Esempio n. 1
0
from gozerbot.generic import getwho
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
    try:
        userhost = getwho(bot, ievent.args[0])
    except IndexError:
        ievent.reply('timebomb requires victim, see !help timebomb.')
        return
Esempio n. 2
0
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
    try:
Esempio n. 3
0
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')
    callbacks.add('PRIVMSG', doaway, awaytest)
    callbacks.add('PRIVMSG', doback, backtest)
    return 1
Esempio n. 4
0
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

#
# projects we pwn
#

def addproject(username, project, desc):
Esempio n. 5
0
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 ;]")


cmnds.add("botsnack", handle_botsnack, ["USER", "CLOUD"])
examples.add(
Esempio n. 6
0
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


def idlecb(bot, ievent):
Esempio n. 7
0
    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


#
# projects we pwn
#
Esempio n. 8
0
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 ;]')

cmnds.add('botsnack', handle_botsnack, ['USER', 'CLOUD'])
examples.add('botsnack', 'give the bot a snack ;] .. botsnack responses \
can be added with botsnack-add', 'botsnack')
Esempio n. 9
0
# 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 = {}
    event['descr'] = ievent.rest.strip()
    event['who'] = []
    if not events.data['eventdict'].has_key(ievent.channel):
        events.data['eventdict'][ievent.channel] = []
Esempio n. 10
0
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
        
def idlecb(bot, ievent):
    """ idle PRIVMSG callback .. set time for channel and nick """
    ttime = time.time()
    idle.data[jsonstring((bot.name, ievent.channel))] = ttime
Esempio n. 11
0
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 = {}
    event['descr'] = ievent.rest.strip()
    event['who'] = []
    if not events.data['eventdict'].has_key(ievent.channel):
        events.data['eventdict'][ievent.channel] = []
    events.data['eventdict'][ievent.channel].append(event)