Exemplo n.º 1
0
    def __init__(self, name):
        self.name = name
        self.conf = ConfigParser.ConfigParser()
        self.conf.read('mods/ubmod/ubmod/{module}'.format(module=name))
        logs.debug('Construyendo modulo [%s]' % name)

        kwargs = {}
        kwargs['module'] = 'ubmod'  # UserBot Virtual Module

        try:
            kwargs['regex'] = self.RegexParser(self.conf.get('config', 'regex'))
            kwargs['help'] = {}
            kwargs['help']['sintax'] = self.conf.get('config', 'sintax')
            kwargs['help']['example'] = self.conf.get('config', 'example')
            kwargs['help']['desc'] = self.conf.get('config', 'descrip')
        except ConfigParser.NoOptionError:
            logs.error('Archivo de configuracion invalido')
            return

        if self.conf.has_option('config', 'alias'):
            kwargs['help']['alias'] = self.conf.get('config', 'alias')

        if self.conf.has_option('config', 'oper'):
            kwargs['oper'] = tuple(self.conf.get('config', 'oper').split())

        if self.conf.has_option('config', 'chan_reqs'):
            kwargs['chan_reqs'] = self.conf.get('config', 'chan_reqs')

        if self.conf.has_option('config', 'privs'):
            kwargs['chan_reqs'] = self.conf.get('config', 'privs')

        try:
            step = 'null'
            if self.conf.has_option('config', 'anyuser'):
                step = 'anyuser'
                kwargs['anyuser'] = self.conf.getboolean('config', 'anyuser')
            if self.conf.has_option('config', 'registered'):
                step = 'registered'
                kwargs['registered'] =\
                self.conf.getboolean('config', 'registered')
            if self.conf.has_option('config', 'channels'):
                step = 'channels'
                kwargs['channels'] =\
                self.conf.getboolean('config', 'channels')
            if self.conf.has_option('config', 'chn_registered'):
                step = 'chn_registered'
                kwargs['chn_registered'] =\
                self.conf.getboolean('config', 'chn_registered')
            if self.conf.has_option('config', 'thread'):
                step = 'thread'
                kwargs['thread'] = self.conf.getboolean('config', 'thread')
            if self.conf.has_option('config', 'logged'):
                step = 'logged'
                kwargs['logged'] = self.conf.getboolean('config', 'logged')
            if self.conf.has_option('config', 'no_prefix'):
                step = 'no_prefix'
                kwargs['no_prefix'] =\
                self.conf.getboolean('config', 'no_prefix')
        except ValueError:
            logs.error('%s: no es "yes" o "no"' % step)
            return

        commands.addHandler(**kwargs)(self.func)
        logs.debug('modulo construido [%s]' % name)

        if True:
            for item, value in kwargs.items():
                if item == 'help':
                    for subitem, subvalue in value.items():
                        logs.debug('    [help][%s]: %s' % (subitem, subvalue))
                else:
                    logs.debug('    [%s]: %s' % (item, value))
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import eightball
reload(eightball)

from sysb import commands
from eightball import lang
from eightball import _

commands.addHandler('games', '(dime|ask|question|eightball) .*', {
    'sintax': "eightball <question>?",
    'example': "eightball i'm sexy?",
    'alias': ('dime', 'ask', 'question'),
    'desc': _('Juego: responde una pregunta de forma aleatoria', lang)},
    anyuser=True)(eightball.eightball)
Exemplo n.º 3
0
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import admin
reload(admin)

from sysb import commands
from admin import lang
from admin import _


commands.addHandler('admin', 'admin id (?P<name>[^ ]+) (?P<passwd>[^ ]+)', {
    'sintax': 'admin id <name> <password>',
    'example': 'admin id root 1234',
    'desc': _('identifica a un usuario como operador en userbot', lang)},
    registered=True,
    logged=True)(admin.operid)


commands.addHandler('admin', 'admin lock (?P<account>[^ ]+) (?P<reason>.*)', {
    'sintax': 'admin lock <account> <reason>',
    'example': 'admin lock fooser bad boy',
    'desc': _('bloquea a un usuario en userbot', lang)},
    registered=True,
    oper=('local', 'global'),
    logged=True)(admin.lock_user)


commands.addHandler('admin', 'admin unlock (?P<account>[^ ]+)', {
    'sintax': 'admin unlock <account>',
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import lag
reload(lag)

from sysb import commands
from lag import lang
from lag import _


commands.addHandler('lag', 'lag( (?P<target>.*))?', {
    'sintax': 'lag <target>?',
    'example': 'lag imcat',
    'desc': _('muestra el lag de un usuario', lang)},
    anyuser=True)
Exemplo n.º 5
0
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import users
reload(users)

from sysb import commands
from users import lang
from users import _


commands.addHandler('users', 'user register', {
    'sintax': 'user register',
    'example': 'user register',
    'desc': _('registra un usuario en el bot', 'es')},
    logged=True)(users.register)


commands.addHandler('users', 'user drop', {
    'sintax': 'user drop',
    'example': 'user drop',
    'desc': _('elimina a un usuario registrado', 'es')},
    registered=True,
    logged=True)(users.drop)


commands.addHandler('users', 'user confirm_drop (?P<code>[^ ]+)', {
    'sintax': 'user confirm_drop <code>',
    'example': 'user confirm_drop 6adf97f83acf6453d4a6a4b1070f3754',
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import help
reload(help)

from sysb import commands
from help import lang
from help import _


commands.addHandler('help', '(help|man|ayuda)( (?P<command>.*))?', {
    'sintax': 'help <command>?',
    'example': 'help help',
    'alias': ('man', 'ayuda'),
    'desc': _('muestra la ayuda de algun comando', lang)},
    anyuser=True)(help.help)
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import google
reload(google)

from sysb import commands
from google import lang
from google import _


commands.addHandler('google', 'img (?P<text2find>.*)', {
    'sintax': 'img <text to find>',
    'example': 'img cats',
    'desc': _('muestra una imagen de algo', lang)},
    anyuser=True)(google.images)


commands.addHandler('google', '(google|gl|search) (?P<text2find>.*)', {
    'sintax': 'google <text to find>',
    'example': 'google google',
    'alias': ('gl', 'search'),
    'desc': _('busca algo en google', lang)},
    anyuser=True)(google.search)
Exemplo n.º 8
0
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import channels
reload(channels)

from sysb import commands
from channels import lang
from channels import _


commands.addHandler('channels', 'chan register( (?P<channel>[^ ]+))?', {
    'sintax': 'chan register <channel>?',
    'example': 'chan register #Foo',
    'desc': _('registra un canal en el bot', lang)},
    registered=True,
    logged=True,
    channels=True,
    chan_reqs='channel')(channels.register)


commands.addHandler('channels', 'chan flags( (?P<channel>#[^ ]+))? (?P<target>['
    '^ ]+) (?P<flags>[^ ]+)', {
    'sintax': 'chan flags <channel>? <target> <flags>',
    'example': 'chan flags #Foo-chan foo-user OP',
    'desc': _('(añade / elimina / edita / muestra) los flags', lang)},
    registered=True,
    logged=True,
    channels=True,
    chn_registered=True,
    privs='s',
Exemplo n.º 9
0
Copyright 2015, Ismael R. Lugo G.
"""

import manager
reload(manager)

from sysb import commands
from manager import lang
from manager import _


commands.addHandler('manager', 'op( (?P<channel>#[^ ]+))?( (?P<target>.*))?',
    {'sintax': 'op <channel>? <target>',
    'example': 'op #Foo fuser fuser2',
    'desc': _('asigna estatus de operador a un usuario', lang)},
    registered=True,
    logged=True,
    channels=True,
    chn_registered=True,
    privs='o',
    chan_reqs='channel')(manager.op)


commands.addHandler('manager', 'deop( (?P<channel>#[^ ]+))?( (?P<target>.*))?',
    {'sintax': 'deop <channel>? <target>',
    'example': 'deop #Foo fuser fuser2',
    'desc': _('remueve el estatus de operador a un usuario', lang)},
    registered=True,
    logged=True,
    channels=True,
    chn_registered=True,
    privs='o',
Exemplo n.º 10
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import ip
reload(ip)

from sysb import commands
from ip import lang
from ip import _


commands.addHandler('ip', 'ip (?P<hostname>[^ ]+)', {
    'sintax': 'ip <hostname>',
    'example': 'ip 8.8.8.8',
    'desc': _('Geolocaliza una ip', lang)},
    anyuser=True)(ip.ip)


commands.addHandler('ip', 'ip2 (?P<hostname>[^ ]+)', {
    'sintax': 'ip2 <hostname>',
    'example': 'ip2 8.8.8.8',
    'desc': _('Geolocaliza una ip', lang)},
    anyuser=True)(ip.ip2)
Exemplo n.º 11
0
# -*- coding: utf-8 -*-
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import translate
reload(translate)

from sysb import commands
from translate import lang
from translate import _


commands.addHandler('translate', '(tr|translate)2 (?P<in>[^ ]+) (?P<out>[^ ]+) '
    '(?P<text>.*)', {'sintax': 'tr2 <input> <output> <text>',
    'example': 'tr2 en es Hello!',
    'alias': ('traslate2',),
    'desc': _('Traduce un texto de un idioma a otro', lang)},
    anyuser=True)(translate.translate2_1)


commands.addHandler('translate', '(tr|translate) (?P<in>[^ ]+) (?P<out>[^ ]+) ('
    '?P<text>.*)', {'sintax': 'tr <input> <output> <text>',
    'example': 'tr en es Hello!',
    'alias': ('traslate',),
    'desc': _('Traduce un texto de un idioma a otro', lang)},
    anyuser=True)(translate.translate2_2)