Exemplo n.º 1
0
from gozerbot.aliases import aliases
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.generic import rlog
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.persist.persiststate import PlugState
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
import re
import urllib, urllib2

plughelp.add('lns', 'use the ln-s.net redirector')

re_url_match = re.compile(r'((?:http|https|ftp)://\S+)')

cfg = PersistConfig()
cfg.define('url-api', 'http://ln-s.net/home/api.jsp')
cfg.define('url-len', 64)

state = None


def init():
    global state
    state = PlugState()
    state.define('ln-s', {})
    return 1


def shutdown():
    state.save()
Exemplo n.º 2
0
from gozerbot.examples import examples
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp

plughelp.add('urban', 'query the urban server')

import re
try:
    import SOAPpy
    __has_soap = True
except ImportError:
    __has_soap = False

__version__ = "1.0"

cfg = PersistConfig()
cfg.define('key', "")
cfg.define('url', "http://api.urbandictionary.com/soap")

def check_requirements(func):
    def wrap(bot, ievent):
	def show_error(msg):
	    """ urban show error message """
	    ievent.reply(msg)
	if not __has_soap:
	    return show_error("You need to install python-soappy for this plugin, on debian/ubuntu you can use apt-get install python-soappy")
	if not len(cfg.data['key'])==32:
	    return show_error("You need to set a license key with !urban-cfg key <my_license_key> from http://www.urbandictionary.org/api.php")
	return func(bot, ievent)
    return wrap
Exemplo n.º 3
0
# Third Party Imports

# Local Imports
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.redispatcher import rebefore

plughelp.add('sed', 'Perform substitution on last message spoken')

cfg = PersistConfig()
cfg.define('cmd_req', 0)
sed_expression = r'^s([/|#.:;])(.*?)\1(.*?)\1?([gi]*)$'
sedre = re.compile(sed_expression)

class LastLine(Pdod):
    def __init__(self):
        self.datadir = os.path.join(datadir, 'plugs', 'sed')
        Pdod.__init__(self, os.path.join(self.datadir, 'sed.data'))
        if not self.data:
            self.data = {}

    def handle_sed(self, bot, ievent):
        """ Perform substitution """
        channel = ievent.channel.lower()
        nick = ievent.nick.lower()
Exemplo n.º 4
0
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.generic import hourmin, rlog, lockdec
from gozerbot.monitor import outmonitor, jabbermonitor
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.irc.ircevent import Ircevent
from gozerbot.fleet import fleet
import time, os, thread

plughelp.add("simplelog", "log irc channels to [hour:min] <nick> txt format")

outlock = thread.allocate_lock()
outlocked = lockdec(outlock)

cfg = PersistConfig()
cfg.define("channels", [])

logfiles = {}
stopped = False

if not os.path.isdir("logs"):
    os.mkdir("logs")
if not os.path.isdir("logs" + os.sep + "simple"):
    os.mkdir("logs" + os.sep + "simple")


def init():
    global stopped
    callbacks.add("ALL", simplelogcb, presimplelogcb)
    jcallbacks.add("ALL", jabbersimplelogcb, jabberpresimplelogcb)
Exemplo n.º 5
0
# plugs/hexonjoin.py
#
#

from gozerbot.callbacks import callbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import struct, socket

plughelp.add('hexjoin', 'show ip and hostname from user joining a channel')

cfg = PersistConfig()
cfg.define('channels', [])

def hexjoin(bot, ievent):
    what = ievent.user
    ip = None
    try:
        ipint = int(what, 16)
        ipint = socket.ntohl(ipint)
        packed = struct.pack('l', ipint)
        ip = socket.inet_ntoa(str(packed))
    except Exception, ex:
        return
    try:
        hostname = socket.gethostbyaddr(ip)[0]
    except:
        if ip:
Exemplo n.º 6
0
try:
    from trac import __version__ as VERSION
    from trac.util import autoreload, daemon
    from trac.web.auth import BasicAuthentication, DigestAuthentication
    from trac.web.main import dispatch_request
    from trac.web.wsgi import WSGIServer, WSGIRequestHandler
    gottrac = True
except ImportError:
    gottrac = False        

from SocketServer import ThreadingMixIn

import os, sys, time, socket, select

cfg = PersistConfig()
cfg.define('startup', '%s --port 10102 -s' % (datadir + os.sep + 'trac'))

plughelp.add('tserver', 'trac server')

if not os.path.isdir(datadir + os.sep + 'trac'):
    os.mkdir(datadir + os.sep + 'trac')

class AuthenticationMiddleware(object):

    def __init__(self, application, auths, single_env_name=None):
        self.application = application
        self.auths = auths
        self.single_env_name = single_env_name
        if single_env_name:
            self.part = 0
Exemplo n.º 7
0
from gozerbot.aliases import aliases
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.generic import rlog
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.persist.persiststate import PlugState
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
import re
import urllib, urllib2

plughelp.add('lns', 'use the ln-s.net redirector')

re_url_match = re.compile(r'((?:http|https|ftp)://\S+)')

cfg = PersistConfig()
cfg.define('url-api', 'http://ln-s.net/home/api.jsp')
cfg.define('url-len', 64)

state = None

def init():
    global state
    state = PlugState()
    state.define('ln-s', {})
    return 1

def shutdown():
    state.save()
    return 1
Exemplo n.º 8
0
#
#
""" do autoreply on incoming jabber private messages except commands. to enable
 use autoreply-cfg txt <message to send>. """

__copyright__ = 'this file is in the public domain'

from gozerbot.commands import cmnds
from gozerbot.callbacks import jcallbacks
from gozerbot.aliases import aliasset
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests

cfg = PersistConfig()
cfg.define('txt', "")

plughelp.add('autoreply', 'jabber autoreply')


def preautoreply(bot, ievent):
    """ check where autoreply callbacks should fire """
    if not ievent.usercmnd and cfg.get('txt') and not ievent.groupchat:
        return 1


def cbautoreply(bot, ievent):
    """ do the auto reply """
    bot.say(ievent.userhost, cfg.get('txt'))
Exemplo n.º 9
0
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerbot.users import users
from gozerbot.generic import getwho, rlog
import time

plughelp.add('throttle', 'throttle user commands per minute')

state = PlugState()
state.define('lasttime', {})
state.define('level', {})
state.define('cpm', {}) # commands per minute

cfg = PersistConfig()
cfg.define('enable', 1)

def throttlepre(bot, ievent):
    if cfg.get('enable'):
        return 1

def throttlecb(bot, ievent):
    try:
        cpm = state['cpm']
        uh = ievent.userhost
        if ievent.usercmnd:
            if cpm.has_key(uh):
                cpm[uh] += 1
            else:
                cpm[uh] = 1
Exemplo n.º 10
0
__copyright__ = 'this file is in the public domain'

from gozerbot.commands import cmnds
from gozerbot.callbacks import callbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.generic import hourmin, rlog
from gozerbot.monitor import outmonitor
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.irc.ircevent import Ircevent
from gozerbot.fleet import fleet
import time, os

plughelp.add('traclog', 'log irc channels in trac format')

cfg = PersistConfig()
cfg.define('channels', [])
cfg.define('tracversion', "0.11")

logfiles = {}

if not os.path.exists('logs/'):
    os.mkdir('logs/')
if not os.path.exists('logs/trac/'):
    os.mkdir('logs/trac/')


def init():
    callbacks.add('ALL', traclogcb, pretraclogcb)
    outmonitor.add('traclog', traclogcb, pretraclogcb)
    return 1
Exemplo n.º 11
0
"""

__copyright__ = 'this file is in the public domain'

from gozerbot.generic import getwho, rlog
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks
from gozerbot.users import users
from gozerbot.plughelp import plughelp
from gozerbot.persist.persistconfig import PersistConfig
import time

plughelp.add('ops', 'op with command or op on join')

cfg = PersistConfig()
cfg.define('oponsplit', 0)


def opjoincb(bot, ievent):
    """ see if we should op a user on join """
    # don't try to op the bot
    if ievent.nick == bot.nick:
        return
    chan = ievent.channel.lower()
    if chan in bot.state['no-op']:
        return
    time.sleep(1)
    if cfg.get('oponsplit') or ievent.nick.lower() not in bot.splitted:
        if users.status(ievent.userhost, ievent.channel.upper()):
            if chan not in bot.state['opchan']:
Exemplo n.º 12
0
__author__ = 'Wijnand Modderman <*****@*****.**>'
__copyright__ = 'BSD'

import time
import urllib
import xml.dom.minidom
from gozerbot.aliases import aliases
from gozerbot.commands import cmnds
from gozerbot.generic import geturl, waitforqueue
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp

plughelp.add('yahoo', 'query yahoo search engine')

cfg = PersistConfig()
cfg.define('appid', '')


# Function: string_to_bool
#   Convert a string argument to a boolean
#
# Parmeters:
#   s - The input string
#
# Returns:
#   bool
def string_to_bool(s):
    sb = {'false': False, 'true': True}
    if sb.has_key(s.lower()):
        return sb[s.lower()]
Exemplo n.º 13
0
from gozerbot.gozerimport import gozer_import
from gozerbot.users import users
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.config import config
from gozerbot.aliases import aliasset
from gozerbot.persist.persistconfig import PersistConfig
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn
from urllib import unquote_plus
from cgi import escape
import time, sys, select, types

plughelp.add('webserver', 'maintain the bots webserver')

cfg = PersistConfig()
cfg.define('webenable', 0)
cfg.define('webport', 8088)
cfg.define('webhost', '')
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit =  cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
Exemplo n.º 14
0
from gozerbot.persist.persist import Persist
from gozerbot.commands import cmnds
from gozerbot.generic import geturl, striphtml, rlog, lockdec
from gozerbot.datadir import datadir
from gozerbot.fleet import fleet
from gozerbot.examples import examples
from gozerbot.threads.thr import start_new_thread
from gozerbot.plughelp import plughelp
from gozerbot.persist.persistconfig import PersistConfig
import os, time, thread

plughelp.add('shoutcast', 'query a shoutcast server or periodically watch \
them')

cfg = PersistConfig()
cfg.define('scwatch', 0)
cfg.define('nodes', [])

sclock = thread.allocate_lock()
locked = lockdec(sclock)

class SCwatcher(object):

    def __init__(self):
        self.stop = False
        self.songsplayed = []

    def run(self):
        self.starttime = int(time.time())
        res = ""
Exemplo n.º 15
0
from gozerbot.persist.pdod import Pdod
from simplejson import dumps
import socket, re, asyncore, time, random, Queue, os

plughelp.add('cloud', 'cloud network')

## UPGRADE PART


def upgrade():
    pass


##33 END UPGRADE PART

cfg = PersistConfig()
cfg.define('enable', 0)
cfg.define('wait', 5)
cfg.define('host', socket.gethostbyname(socket.getfqdn()))
cfg.define('name', socket.getfqdn())
cfg.define('port', 10101)
cfg.define('disable', [])
cfg.define('booturl', 'http://gozerbot.org:10101/')
cfg.define('servermode', 0)

waitre = re.compile(' wait (\d+)', re.I)
hp = "%s:%s" % (cfg.get('host'), cfg.get('port'))
url = "http://%s" % hp

# CLIENT PART
Exemplo n.º 16
0
__author__ = 'Wijnand Modderman <*****@*****.**>'
__copyright__ = 'BSD'

import time
import urllib
import xml.dom.minidom
from gozerbot.aliases import aliases
from gozerbot.commands import cmnds
from gozerbot.generic import geturl, waitforqueue
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp

plughelp.add('yahoo', 'query yahoo search engine')

cfg = PersistConfig()
cfg.define('appid', '')

# Function: string_to_bool
#   Convert a string argument to a boolean
#
# Parmeters:
#   s - The input string
#
# Returns:
#   bool
def string_to_bool(s):
    sb = {'false': False, 'true': True}
    if sb.has_key(s.lower()):
        return sb[s.lower()]
    return bool(s)
Exemplo n.º 17
0
#
#

__depend__ = ['karma', ]

from gozerbot.aliases import aliases
from gozerbot.commands import cmnds
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerplugs.karma import karma
import shlex

plughelp.add('fans', 'show the lovers and haters of a karma item')

cfg = PersistConfig()
cfg.define('dehighlight', 1)

def dehighlight(nick):
    l = len(nick)
    if l > 1:
        return nick[0:l//2] + '\x030\x03' + nick[l//2:]
    else:
        return nick

def getkarma(item):
    nicks = {}
    ups = karma.getwhoup(item) or []
    dns = karma.getwhodown(item) or []
    nicks = dict((x, 0) for x in set(ups+dns))
    for nick in ups: nicks[nick] += 1
Exemplo n.º 18
0
#

__license__ = 'this file is in the public domain'
__gendocfirst__ = ['register-enable', ]

from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks
from gozerbot.users import users
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerplugs.throttle import state as throttlestate

plughelp.add('register', 'allow registering of anon users')

cfg = PersistConfig()
cfg.define('enable', 0)
cfg.define('perms', ['USER', ])

def handle_register(bot, ievent):
    if not cfg.get('enable'):
        ievent.reply('register is not enabled')
        return
    if 'OPER' in cfg.get('perms'):
        ievent.reply("can't use OPER permission in register command")
        return
    if not ievent.rest:
        ievent.missing('<username>')
        return
    name = ievent.args[0]
    if users.exist(name):
Exemplo n.º 19
0
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.threads.thr import start_new_thread

plughelp.add("mpd", "music player daemon control")

## UPGRADE PART


def upgrade():
    convertpickle(
        datadir + os.sep + "old" + os.sep + "mpd", datadir + os.sep + "plugs" + os.sep + "mpd" + os.sep + "mpd"
    )


cfg = PersistConfig()
cfg.define("server-host", "127.0.0.1")
cfg.define("server-port", 6600)
cfg.define("server-pass", "")
cfg.define("socket-timeout", 15)
cfg.define("watcher-interval", 10)
cfg.define("watcher-enabled", 0)
cfg.define("song-status", 'now playing: %(artist)s - %(title)s on "%(album)s" (duration: %(time)s)')


class MPDError(Exception):
    pass


class MPDDict(dict):
    def __getitem__(self, item):
Exemplo n.º 20
0
# gozerplugs/lart.py
#
#

from gozerbot.commands import cmnds
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import random

plughelp.add('lart', 'do the lart')

cfg = PersistConfig()
cfg.define('lartlist', [])


def handle_lart(bot, ievent):
    try:
        who = ievent.args[0]
    except IndexError:
        ievent.missing('<who>')
        return
    try:
        txt = random.choice(cfg.get('lartlist'))
    except IndexError:
        ievent.reply(
            'lart list is empty .. use lart-add to add entries .. use "<who>" as a nick holder'
        )
        return
    txt = txt.replace('<who>', who)
Exemplo n.º 21
0
# Author: Wijnand 'tehmaze' Modderman
# Website: http://tehmaze.com
# License: BSD

from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
import os, time

plughelp.add("seen", "remember what people said for the last time")

cfg = PersistConfig()
cfg.define("tz", "+0100")


class Seen(Pdod):
    def __init__(self):
        self.datadir = datadir + os.sep + "plugs" + os.sep + "seen"
        Pdod.__init__(self, os.path.join(self.datadir, "seen.data"))

    def handle_seen(self, bot, ievent):
        if not ievent.args:
            ievent.missing("<nick>")
            return
        nick = ievent.args[0].lower()
        if not self.data.has_key(nick):
            alts = [x for x in self.data.keys() if nick in x]
Exemplo n.º 22
0
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.plughelp import plughelp
from gozerbot.plugins import plugins
from gozerbot.threads.thr import start_new_thread
from gozerbot.utils.statdict import Statdict
from gozerbot.utils.limlist import Limlist
from os.path import join as _j
import time, re, random, types

from gozerbot.persist.persistconfig import PersistConfig

plughelp.add('markov', 'Gozerbot speaking madness')

cfg = PersistConfig()
cfg.define('enable', [])
cfg.define('command', 1)
cfg.define('onjoin', [])

def enabled(botname, channel):
    if jsonstring([botname, channel]) in cfg['enable']:
        return True

# Markers (is Marker the correct name for this?)
class Marker: pass
class BeginMarker(Marker): pass
class EndMarker(Marker): pass
class NickMarker(Marker): pass

# Tokens
Exemplo n.º 23
0
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.plughelp import plughelp
from gozerbot.plugins import plugins
from gozerbot.threads.thr import start_new_thread
from gozerbot.utils.statdict import Statdict
from gozerbot.utils.limlist import Limlist
from os.path import join as _j
import time, re, random, types

from gozerbot.persist.persistconfig import PersistConfig

plughelp.add('markov', 'Gozerbot speaking madness')

cfg = PersistConfig()
cfg.define('enable', [])
cfg.define('command', 1)
cfg.define('onjoin', [])


def enabled(botname, channel):
    if jsonstring([botname, channel]) in cfg['enable']:
        return True


# Markers (is Marker the correct name for this?)
class Marker:
    pass

Exemplo n.º 24
0
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.threads.thr import start_new_thread

plughelp.add('mpd', 'music player daemon control')

## UPGRADE PART


def upgrade():
    convertpickle(datadir + os.sep + 'old' + os.sep + 'mpd', \
datadir + os.sep + 'plugs' + os.sep + 'mpd' + os.sep + 'mpd')


cfg = PersistConfig()
cfg.define('server-host', '127.0.0.1')
cfg.define('server-port', 6600)
cfg.define('server-pass', '')
cfg.define('socket-timeout', 15)
cfg.define('watcher-interval', 10)
cfg.define('watcher-enabled', 0)
cfg.define(
    'song-status',
    'now playing: %(artist)s - %(title)s on "%(album)s" (duration: %(time)s)')


class MPDError(Exception):
    pass

Exemplo n.º 25
0
from gozerbot.persist.persiststate import PersistState
from gozerbot.datadir import datadir
from gozerbot.persist.pdod import Pdod
from simplejson import dumps
import socket, re, asyncore, time, random, Queue, os

plughelp.add('cloud', 'cloud network')

## UPGRADE PART

def upgrade():
    pass

##33 END UPGRADE PART

cfg = PersistConfig()
cfg.define('enable', 0)
cfg.define('wait', 5)
cfg.define('host' , socket.gethostbyname(socket.getfqdn()))
cfg.define('name' , socket.getfqdn())
cfg.define('port' , 10101)
cfg.define('disable', [])
cfg.define('booturl', 'http://gozerbot.org:10101/')
cfg.define('servermode', 0)

waitre = re.compile(' wait (\d+)', re.I)
hp = "%s:%s" % (cfg.get('host'), cfg.get('port'))
url = "http://%s" % hp

# CLIENT PART
Exemplo n.º 26
0
from socket    import gethostbyaddr
from socket    import gethostbyname, gaierror
from time      import time, sleep
from Queue     import Queue, Empty
from threading import Thread
import re
from gozerbot.commands      import cmnds
from gozerbot.generic       import rlog
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.users         import users
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp

plughelp.add('rblcheck', 'check blacklists')

cfg = PersistConfig()
cfg.define('throttle', 60)
cfg.define('max-threads', 5)
cfg.define('debug', 0)
debug = 0

def list_check(list, chkip):
    results = []
    for i in list.keys():
        chk = "%s.%s" % (".".join(reversed(chkip.split("."))), list[i][0])
        try: qr = gethostbyname("%s" % (chk))
        except: qr = None
        if qr:
            results.append(list[i])
            if cfg.get('debug'):
                rlog(10, 'rblcheck', '%s result: %s' % (chk, str(qr)))
Exemplo n.º 27
0
__copyright__ = 'this file is in the public domain'

from gozerbot.commands import cmnds
from gozerbot.callbacks import callbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.generic import hourmin, rlog
from gozerbot.monitor import outmonitor
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.irc.ircevent import Ircevent
from gozerbot.fleet import fleet
import time, os

plughelp.add('traclog', 'log irc channels in trac format')

cfg = PersistConfig()
cfg.define('channels', [])
cfg.define('tracversion', "0.11")

logfiles = {}

if not os.path.exists('logs/'):
    os.mkdir('logs/')
if not os.path.exists('logs/trac/'):
    os.mkdir('logs/trac/')

def init():
    callbacks.add('ALL', traclogcb, pretraclogcb)
    outmonitor.add('traclog', traclogcb, pretraclogcb)
    return 1
Exemplo n.º 28
0
__depend__ = [
    'karma',
]

from gozerbot.aliases import aliases
from gozerbot.commands import cmnds
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerplugs.karma import karma
import shlex

plughelp.add('fans', 'show the lovers and haters of a karma item')

cfg = PersistConfig()
cfg.define('dehighlight', 1)


def dehighlight(nick):
    l = len(nick)
    if l > 1:
        return nick[0:l // 2] + '\x030\x03' + nick[l // 2:]
    else:
        return nick


def getkarma(item):
    nicks = {}
    ups = karma.getwhoup(item) or []
    dns = karma.getwhodown(item) or []
Exemplo n.º 29
0
import os

from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.fleet import fleet
from gozerbot.generic import geturl2
from gozerbot.periodical import periodical
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.persist.pdod import Pdod
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import gozerbot.threads.thr as thr

plughelp.add('httpwatch', 'periodically check urls')

cfg = PersistConfig()
cfg.define('sleep', 300)
cfg.define('run', True)


class HttpWatch(Pdod):

    pid = None

    def __init__(self):
        self.datadir = datadir + os.sep + 'plugs' + os.sep + 'httpwatch'
        Pdod.__init__(self, os.path.join(self.datadir, 'httpwatch.data'))
        if not 'urls' in self.data:
            self.data['urls'] = {}
        if not 'send' in self.data:
            self.data['send'] = {}
Exemplo n.º 30
0
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.generic import hourmin, rlog, lockdec
from gozerbot.monitor import outmonitor, jabbermonitor
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.irc.ircevent import Ircevent
from gozerbot.fleet import fleet
import time, os, thread

plughelp.add('supylog', 'log irc channels in supybot channellogger format')

outlock = thread.allocate_lock()
outlocked = lockdec(outlock)

cfg = PersistConfig()
cfg.define('channels', [])
cfg.define('logtimestamp', '%Y-%m-%dT%H:%M:%S')
cfg.define('filenametimestamp', '%d-%a-%Y')
cfg.define('nologprefix', '[nolog]')
cfg.define('nologmsg', '-= THIS MESSAGE NOT LOGGED =-')

logfiles = {}
stopped = False

nonchanevents = ['NICK', 'NOTICE', 'QUIT']

if not os.path.isdir('logs'):
    os.mkdir('logs')
if not os.path.isdir('logs' + os.sep + 'supy'):
    os.mkdir('logs' + os.sep + 'supy')
Exemplo n.º 31
0
from gozerbot.generic import decode_html_entities, get_encoding, geturl, \
geturl2, rlog, handle_exception
from gozerbot.persist.persist import Persist
from gozerbot.persist.persistconfig import PersistConfig
import urllib
import urllib2
import urlparse
import copy
import re
import socket

plughelp.add('snarf', 'the snarf plugin gets the title of the web page of \
the provided url or the last url in the log')

cfg           = Persist('snarf', {})
pcfg          = PersistConfig()
pcfg.define('allow', ['text/plain', 'text/html', 'application/xml'])
re_html_title = re.compile(u'<title>(.*)</title>', re.I | re.M | re.S)
re_url_match  = re.compile(u'((?:http|https)://\S+)')
re_html_valid = {
    'result':   re.compile('(Failed validation, \
\d+ errors?|Passed validation)', re.I | re.M),
    'modified': re.compile('<th>Modified:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'server':   re.compile('<th>Server:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'size':     re.compile('<th>Size:</th><td colspan="2">\
([^<]+)</td>', re.I | re.M),
    'content':  re.compile('<th>Content-Type:</th><td colspan="2">\
([^<]+)</td>', re.I | re.M),
    'encoding': re.compile('<td>([^<]+)</td><td><select name="charset" \
Exemplo n.º 32
0
__copyright__ = 'this file is in the public domain'

from gozerbot.fleet import fleet
from gozerbot.generic import rlog, handle_exception, strippedtxt, lockdec
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.config import config
from gozerbot.plughelp import plughelp
from gozerbot.partyline import partyline
from gozerbot.threads.thr import start_new_thread
from gozerbot.contrib.rijndael import rijndael
import socket, re, time, Queue

plughelp.add('tcp' , 'run the tcp listen thread')

cfg = PersistConfig()
cfg.define('tcp', 0) # set to 1 to enable
cfg.define('tcpparty', 0)
cfg.define('tcpipv6', 0)
cfg.define('tcpmasks', ['192.168*', ]) 
cfg.define('tcphost', "localhost")
cfg.define('tcpport', 5500)
cfg.define('tcpallow', ["127.0.0.1", ])
cfg.define('tcpallowednicks', ["#gozerbot", "dunker"])
cfg.define('tcppassword', "mekker", exposed=False)
cfg.define('tcpseed', "blablablablablaz", exposed=False) # needs to be 16 chars
cfg.define('tcpstrip', 1) # strip all chars < char(32)
cfg.define('tcpsleep', 0) # sleep in sendloop .. can be used to delay packet traffic
cfg.define('tdpdblog', 0)
cfg.define('tcpbot', 'default')
Exemplo n.º 33
0
#

""" do autoreply on incoming jabber private messages except commands. to enable
 use autoreply-cfg txt <message to send>. """

__copyright__ = 'this file is in the public domain'

from gozerbot.commands import cmnds
from gozerbot.callbacks import jcallbacks
from gozerbot.aliases import aliasset
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests

cfg = PersistConfig()
cfg.define('txt', "")

plughelp.add('autoreply', 'jabber autoreply')

def preautoreply(bot, ievent):
    """ check where autoreply callbacks should fire """
    if not ievent.usercmnd and cfg.get('txt') and not ievent.groupchat:
        return 1

def cbautoreply(bot, ievent):
    """ do the auto reply """
    bot.say(ievent.userhost, cfg.get('txt'))

jcallbacks.add('Message', cbautoreply, preautoreply)
Exemplo n.º 34
0
try:
    from trac import __version__ as VERSION
    from trac.util import autoreload, daemon
    from trac.web.auth import BasicAuthentication, DigestAuthentication
    from trac.web.main import dispatch_request
    from trac.web.wsgi import WSGIServer, WSGIRequestHandler
    gottrac = True
except ImportError:
    gottrac = False

from SocketServer import ThreadingMixIn

import os, sys, time, socket, select

cfg = PersistConfig()
cfg.define('startup', '%s --port 10102 -s' % (datadir + os.sep + 'trac'))

plughelp.add('tserver', 'trac server')

if not os.path.isdir(datadir + os.sep + 'trac'):
    os.mkdir(datadir + os.sep + 'trac')


class AuthenticationMiddleware(object):
    def __init__(self, application, auths, single_env_name=None):
        self.application = application
        self.auths = auths
        self.single_env_name = single_env_name
        if single_env_name:
            self.part = 0
Exemplo n.º 35
0
from socket import gethostbyaddr
from socket import gethostbyname, gaierror
from time import time, sleep
from Queue import Queue, Empty
from threading import Thread
import re
from gozerbot.commands import cmnds
from gozerbot.generic import rlog
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.users import users
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp

plughelp.add('rblcheck', 'check blacklists')

cfg = PersistConfig()
cfg.define('throttle', 60)
cfg.define('max-threads', 5)
cfg.define('debug', 0)
debug = 0


def list_check(list, chkip):
    results = []
    for i in list.keys():
        chk = "%s.%s" % (".".join(reversed(chkip.split("."))), list[i][0])
        try:
            qr = gethostbyname("%s" % (chk))
        except:
            qr = None
        if qr:
Exemplo n.º 36
0
__gendocfirst__ = ["anon-enable"]
__depend__ = ["throttle"]

from gozerbot.generic import rlog, jsonstring
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks
from gozerbot.users import users
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests
from gozerplugs.throttle import state as throttlestate

plughelp.add("anon", "allow registering of anon users on JOIN")

cfg = PersistConfig()
cfg.define("enable", [])  # (bot.name, ievent.channel) pair
cfg.define("perms", ["USER"])


def anonpre(bot, ievent):
    if "OPER" not in cfg.get("perms") and jsonstring([bot.name, ievent.channel]) in cfg.get("enable"):
        return 1


def anoncb(bot, ievent):
    try:
        username = users.getname(ievent.userhost)
        if not username:
            if users.add(ievent.nick, [ievent.userhost], perms=cfg.get("perms")):
                throttlestate["level"][ievent.userhost] = 10
Exemplo n.º 37
0
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.users import users
from gozerbot.utils.generic import convertpickle
import copy
import os
import re
import urllib, urllib2
import xml.dom.minidom

plughelp.add(
    'bugtracker',
    'various bug tracker support, define a bugtracker for the channel with bugtracker-set'
)

cfg = PersistConfig()
cfg.define('sep', '..')


class BugTrackerNotFound(Exception):
    pass


class BugTrackerNotImplemented(Exception):
    pass


class BugTrackerNotSupported(Exception):
    pass

Exemplo n.º 38
0
from gozerbot.users import users
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.callbacks import callbacks
from gozerbot.plughelp import plughelp
import random, os

plughelp.add('greeting', 'the greeting plugin allows users to set messages \
to be said when they join a channel')

## UPGRADE PART

def upgrade():
    convertpickle(datadir + os.sep + 'old' + os.sep + 'greetings', \
datadir + os.sep + 'plugs' + os.sep + 'greeting' + os.sep + 'greetings')

cfg = PersistConfig()
cfg.define('enable', [])

greetings = None

def init():
    """ init the greeting plugin """
    global greetings
    greetings = Pdol(datadir + os.sep + 'plugs' + os.sep + 'greeting' + \
os.sep + 'greetings')
    if not greetings.data:
        upgrade()
        greetings = Pdol(datadir + os.sep + 'plugs' + os.sep + 'greeting' + \
os.sep + 'greetings')
    return 1
Exemplo n.º 39
0
# Author: Wijnand 'tehmaze' Modderman
# Website: http://tehmaze.com
# License: BSD

from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
import os, time

plughelp.add('seen', 'remember what people said for the last time')

cfg = PersistConfig()
cfg.define('tz', '+0100')


class Seen(Pdod):
    def __init__(self):
        self.datadir = datadir + os.sep + 'plugs' + os.sep + 'seen'
        Pdod.__init__(self, os.path.join(self.datadir, 'seen.data'))

    def handle_seen(self, bot, ievent):
        if not ievent.args:
            ievent.missing('<nick>')
            return
        nick = ievent.args[0].lower()
        if not self.data.has_key(nick):
            alts = [x for x in self.data.keys() if nick in x]
Exemplo n.º 40
0
# plugs/hexonjoin.py
#
#

from gozerbot.callbacks import callbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import struct, socket

plughelp.add('hexjoin', 'show ip and hostname from user joining a channel')

cfg = PersistConfig()
cfg.define('channels', [])


def hexjoin(bot, ievent):
    what = ievent.user
    ip = None
    try:
        ipint = int(what, 16)
        ipint = socket.ntohl(ipint)
        packed = struct.pack('l', ipint)
        ip = socket.inet_ntoa(str(packed))
    except Exception, ex:
        return
    try:
        hostname = socket.gethostbyaddr(ip)[0]
    except:
Exemplo n.º 41
0
    'throttle',
]

from gozerbot.generic import rlog, jsonstring
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.callbacks import callbacks
from gozerbot.users import users
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests
from gozerplugs.throttle import state as throttlestate

plughelp.add('anon', 'allow registering of anon users on JOIN')

cfg = PersistConfig()
cfg.define('enable', [])  # (bot.name, ievent.channel) pair
cfg.define('perms', [
    'USER',
])


def anonpre(bot, ievent):
    if 'OPER' not in cfg.get('perms') and \
jsonstring([bot.name, ievent.channel]) in cfg.get('enable'):
        return 1


def anoncb(bot, ievent):
    try:
        username = users.getname(ievent.userhost)
Exemplo n.º 42
0
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.generic import hourmin, rlog, lockdec
from gozerbot.monitor import outmonitor, jabbermonitor
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.irc.ircevent import Ircevent
from gozerbot.fleet import fleet
import time, os, thread

plughelp.add('supylog', 'log irc channels in supybot channellogger format')

outlock = thread.allocate_lock()
outlocked = lockdec(outlock)

cfg = PersistConfig()
cfg.define('channels', [])
cfg.define('logtimestamp', '%Y-%m-%dT%H:%M:%S')
cfg.define('filenametimestamp', '%d-%a-%Y')
cfg.define('nologprefix', '[nolog]')
cfg.define('nologmsg', '-= THIS MESSAGE NOT LOGGED =-')

logfiles = {}
stopped = False

nonchanevents = ['NICK','NOTICE','QUIT']

if not os.path.isdir('logs'):
    os.mkdir('logs')
if not os.path.isdir('logs' + os.sep + 'supy'):
    os.mkdir('logs' + os.sep + 'supy')
Exemplo n.º 43
0
from gozerbot.examples import examples
from gozerbot.generic import geturl, geturl2, striphtml, useragent
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.users import users
from gozerbot.utils.generic import convertpickle
import copy
import os
import re
import urllib, urllib2
import xml.dom.minidom

plughelp.add('bugtracker', 'various bug tracker support, define a bugtracker for the channel with bugtracker-set')

cfg = PersistConfig()
cfg.define('sep', '..')

class BugTrackerNotFound(Exception):
    pass

class BugTrackerNotImplemented(Exception):
    pass

class BugTrackerNotSupported(Exception):
    pass

class BugTracker:

    bugurls = [] # regexp patterns that could match a bugtracker url
    bugtags = re.compile('(?:bug|ticket)\s?#(\d+)', re.I)
Exemplo n.º 44
0
# http://paste-it.net client for gozerbot (trough pipes)
# Wijnand 'tehmaze' Modderman - http://tehmaze.com
# BSD License

from gozerbot.commands import cmnds
from gozerbot.config import config
from gozerbot.generic import useragent, waitforqueue
from gozerbot.plughelp import plughelp
from gozerbot.persist.persistconfig import PersistConfig
import copy
import optparse
import urllib
import urllib2

cfg = PersistConfig()
cfg.define('url', 'http://www.paste-it.net/ajax/pit/')
cfg.define('expiry', 604800)
cfg.define('items', 50)
cfg.define('waitforqueue', 50)
cfg.define('useragent', 'paste-it.net command line client (Compatible; %s)' % ' '.join(config['version'].split()[0:2]))

plughelp.add('pit', 'http://www.paste-it.net paste functionality')

class PitOptionParser(optparse.OptionParser):
    def __init__(self, ievent):
        optparse.OptionParser.__init__(self)
        self.ievent = ievent
        self.ievent.stop = False
        self.formatter = optparse.IndentedHelpFormatter(0, 24, None, 1)
        self.formatter.set_parser(self)
Exemplo n.º 45
0
geturl2, rlog, handle_exception
from gozerbot.persist.persist import Persist
from gozerbot.persist.persistconfig import PersistConfig
import urllib
import urllib2
import urlparse
import copy
import re
import socket

plughelp.add(
    'snarf', 'the snarf plugin gets the title of the web page of \
the provided url or the last url in the log')

cfg = Persist('snarf', {})
pcfg = PersistConfig()
pcfg.define('allow', ['text/plain', 'text/html', 'application/xml'])
re_html_title = re.compile(u'<title>(.*)</title>', re.I | re.M | re.S)
re_url_match = re.compile(u'((?:http|https)://\S+)')
re_html_valid = {
    'result':
    re.compile('(Failed validation, \
\d+ errors?|Passed validation)', re.I | re.M),
    'modified':
    re.compile('<th>Modified:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'server':
    re.compile('<th>Server:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'size':
    re.compile('<th>Size:</th><td colspan="2">\
Exemplo n.º 46
0
# Third Party Imports

# Local Imports
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.redispatcher import rebefore

plughelp.add('sed', 'Perform substitution on last message spoken')

cfg = PersistConfig()
cfg.define('cmd_req', 0)
sed_expression = r'^s([/|#.:;])(.*?)\1(.*?)\1?([gi]*)$'
sedre = re.compile(sed_expression)


class LastLine(Pdod):
    def __init__(self):
        self.datadir = os.path.join(datadir, 'plugs', 'sed')
        Pdod.__init__(self, os.path.join(self.datadir, 'sed.data'))
        if not self.data:
            self.data = {}

    def handle_sed(self, bot, ievent):
        """ Perform substitution """
        channel = ievent.channel.lower()
Exemplo n.º 47
0
from gozerbot.gozerimport import gozer_import
from gozerbot.users import users
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.config import config
from gozerbot.aliases import aliasset
from gozerbot.persist.persistconfig import PersistConfig
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn
from urllib import unquote_plus
from cgi import escape
import time, sys, select, types

plughelp.add('webserver', 'maintain the bots webserver')

cfg = PersistConfig()
cfg.define('webenable', 0)
cfg.define('webport', 8088)
cfg.define('webhost', '')
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit = cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
Exemplo n.º 48
0
# gozerplugs/lart.py
#
#

from gozerbot.commands import cmnds
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import random

plughelp.add("lart", "do the lart")

cfg = PersistConfig()
cfg.define("lartlist", [])


def handle_lart(bot, ievent):
    try:
        who = ievent.args[0]
    except IndexError:
        ievent.missing("<who>")
        return
    try:
        txt = random.choice(cfg.get("lartlist"))
    except IndexError:
        ievent.reply('lart list is empty .. use lart-add to add entries .. use "<who>" as a nick holder')
        return
    txt = txt.replace("<who>", who)
    bot.action(ievent.channel, txt)
Exemplo n.º 49
0
import os

from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.fleet import fleet
from gozerbot.generic import geturl2
from gozerbot.periodical import periodical
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.persist.pdod import Pdod
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
import gozerbot.threads.thr as thr

plughelp.add('httpwatch', 'periodically check urls')

cfg = PersistConfig()
cfg.define('sleep', 300)
cfg.define('run', True)

class HttpWatch(Pdod):
    
    pid = None

    def __init__(self):
        self.datadir = datadir + os.sep + 'plugs' + os.sep + 'httpwatch'
        Pdod.__init__(self, os.path.join(self.datadir, 'httpwatch.data'))
        if not 'urls' in self.data:
            self.data['urls'] = {}
        if not 'send' in self.data:
            self.data['send'] = {}
            self.save()