Esempio n. 1
0
def cmdChannels(obj):
    obj.pmu('Channels List: (this may take a second)')
    for chan in A.red.smembers('i.%s.chans' % obj.nid):
        numu = A.red.scard('i.%s.chan.%s.users' % (obj.nid, chan))
        numop = A.red.scard('i.%s.chan.%s.ops' % (obj.nid, chan))
        obj.pmu('[#%s] Users: %s | OPs: %s' % (chan, numu, numop))
        A.throttle()
Esempio n. 2
0
def cmdCommands(obj):
    obj.pmu('Command List: (this may take a second)')
    k = A.commands.keys()
    k.sort()
    for name in k:
        i = A.commands[name]
        if i['nolist']: continue
        obj.pmu('  [%s%s]: %s' % (A.prefix, name, i['desc']))
        A.throttle()
Esempio n. 3
0
def loopCall():
    for k in A.red.keys('i.p.core.spam.*'):
        if A.red.hget(k, 'active').isdigit() and float(A.red.hget(k, 'active')):
            if float(A.red.hget(k, 'end')) != -1 and time.time() > float(A.red.hget(k, 'end')):
                A.red.hset(k, 'active', 0)
                continue
            if float(time.time()-float(A.red.hget(k, 'last'))) < float(A.red.hget(k, 'time')):
                continue
            A.callHook('core_spam_push', float(k.split('.')[-1]))
Esempio n. 4
0
def clanSpam(net, msg, force):
    attempts, success = 0, 0
    for chan in A.red.smembers('i.%s.chans' % net):
        attempts += 1
        _v = A.red.get('i.%s.chan.%s.cfg.clanspam' % (net, chan))
        if _v and not int(_v): continue
        A.write(net, chan, msg)
        success += 1
    return attempts, success
Esempio n. 5
0
def cmdUpdate(obj):
    obj.reply('Searching for updates on the git repo...')
    l = os.popen('git pull origin dev').readlines()
    if 'Already up-to-date.\n' in l:
        return obj.reply("No updates availible from git!")
    A.red.set("i.maintmode", int(1))
    obj.reply("An update was found on the git repo!")
    obj.reply('Updating and reloading...')
    A.reloadPlugins(obj.reply, 'Update complete!')
    A.red.set("i.maintmode", int(0))
Esempio n. 6
0
def adminAddReport(msg, nick, chan, net):
    id = A.red.incr('i.p.core.reportid')
    k = 'i.p.core.rep.%s' % id
    A.red.hset(k, 'user', nick)
    A.red.hset(k, 'chan', chan)
    A.red.hset(k, 'msg', msg)
    A.red.hset(k, 'active', 1)
    for i in cfg.admin_chans:
        if chan: c = '[%s]' % chan
        else: c = ''
        A.write(net, i,
                'NEW REPORT #%s FILED BY %s: %s %s' % (id, nick, msg, c))
    return True, id
Esempio n. 7
0
def coreSpamPush(id, update_time=True):
    print 'Pushing %s' % id
    k = 'i.p.core.spam.%s' % id
    if update_time: A.red.hset(k, 'last',   time.time())
    try: data = json.loads(A.red.hget(k, 'data'))
    except:
        print 'Failed to push spam "%s"!' % id
        return
    for chan in data['chans']:
        _v = A.red.get('i.%s.chan.%s.cfg.spams' % (data['nid'], chan))
        if _v and not int(_v): continue
        if A.red.sismember('i.%s.chans' % data['nid'], chan):
            A.write(data['nid'], chan, data['msg'])
        else: print 'Not in channel %s' % chan #@TODO Fix this
Esempio n. 8
0
def cmdAddspam(obj):
    if not obj.kwargs: return obj.usage()
    if 'msg' not in obj.kwargs or 'time' not in obj.kwargs or 'duration' not in obj.kwargs: return obj.usage()
    obj.sess['time'] = obj.kwargs.get('time')
    obj.sess['duration'] = obj.kwargs.get('duration')
    obj.sess['channels'] = obj.kwargs.get('chans', '')
    obj.sess['chans'] = list(A.red.smembers('i.%s.chans' % obj.nid))
    if obj.sess['channels']:
        obj.sess['chans'] = [i.strip().replace('#', '') for i in obj.sess['channels'].split(',')]
    else: return obj.reply('Incorrect format for kwarg "chans"')
    if not obj.sess['duration'].isdigit() and obj.sess['time'].isdigit():
        return obj.reply('Time and Duration kwargs must be integers (numbers)')
    num = A.callHook('core_spam_add', obj.nid, obj.kwargs.get('msg'), obj.sess['chans'], int(obj.kwargs.get('duration')), int(obj.kwargs.get('time')))
    obj.reply('Spam #%s was added!' % num)
    if obj.kwargs.get('spam'): A.callHook('core_spam_push', num)
Esempio n. 9
0
def cmdAddCw(obj):
    if not obj.op:
        return obj.reply(
            "You must be an admin of the channel to request a cw or pcw!")
    if not 'players' in obj.kwargs or not 'gm' in obj.kwargs:
        return obj.usage()
    if A.red.exists('i.p.clan.cw.%s' % obj.dest):
        return obj.reply(
            "You've already spammed a cw or pcw in the past 15 minutes! Please wait before spamming again!"
        )
    if not obj.kwargs.get('players').isdigit():
        return obj.reply("Players must be an INTEGER value (a number ;D)")
    cw = {
        'nump': obj.kwargs.get('players'),
        'gm': obj.kwargs.get('gm'),
        'notes': obj.kwargs.get("notes"),
        'practice': obj.kwargs.get('practice', False),
        'chan': obj.dest,
        'id': getID()
    }
    A.red.hmset('i.p.clan.cw.%s' % obj.dest, cw)
    A.red.expire('i.p.clan.cw.%s' % obj.dest, 900)
    a, s = A.callHook('clan_spam_msg', obj.nid, genMessage(cw), False)
    obj.reply('Your clan (ID #%s) war was spammed to %s out of %s channels!' %
              (cw['id'], s, a))
Esempio n. 10
0
def coreLoop():
    for chan in config.channels:
        try:
            r = requests.get(ELIVE % chan['id']).json
        except:
            print 'Could not grab Justin.tv API for %s' % chan['id']
            continue
        if len(r):
            msg = '%s IS LIVE NOW: %s' % (chan['name'].upper(), r[0]['title'])
            spams = []
            A.red.set('i.p.scer.%s.live' % chan['id'], 1)
            if chan['spam']:
                for spam in chan['spams']:
                    spams.append(
                        A.callHook('core_spam_add',
                                   chan['nid'],
                                   msg,
                                   spam['chans'],
                                   -1,
                                   spam['delay'],
                                   active=0))
            A.write(chan['nid'], chan['chan'],
                    "The stream '%s' has gone live!" % chan['name'])
            if len(spams):
                A.write(
                    chan['nid'], chan['chan'],
                    "Automatically added the following (inactive) spams: %s" %
                    (', '.join(spams)))
        elif not len(r):
            i = A.red.get('i.p.scer.%s.live' % chan['id'])
            if i and int(i):
                A.red.set('i.p.scer.%s.live' % chan['id'], 0)
                A.write("The stream '%s' has stop broadcasting!" %
                        chan['name'])
Esempio n. 11
0
def cmdEditspam(obj):
    if not obj.kwargs: return obj.usage()
    if not obj.m[1].isdigit(): return obj.reply('That is an invalid ID #!')
    if 'i.p.core.spam.%s' % int(obj.m[1]) not in A.red.keys('i.p.core.spam.*'): return obj.reply('No spam with that ID #!')
    s = 'i.p.core.spam.%s' % int(obj.m[1])
    obj.sess['data'] = json.loads(A.red.hget(s, 'data'))
    if 'msg' in obj.kwargs: obj.sess['data']['msg'] = obj.kwargs.get('msg')
    elif 'time' in obj.kwargs:
        if not obj.kwargs.get('time').isdigit(): return obj.reply('Time kwarg must be integer (number)!')
        print 'Time == %s' % str(int(obj.kwargs.get('time'))*60)
        A.red.hset(s, 'time', int(obj.kwargs.get('time'))*60)
    elif 'duration' in obj.kwargs:
        if not obj.kwargs.get('time').isdigit(): return obj.reply('Duration kwarg must be integer (number)!')
        if obj.kwargs.get('duration')[0] in ['-']: A.red.hset(s, 'end', 0)
        else: A.red.hset(s, 'end', time.time()+(int(obj.kwargs.get('duration')*60)))
    elif 'active' in obj.kwargs:
        A.red.hset(s, 'active', int(obj.kwargs.get('active')))
    elif 'delete' in obj.kwargs:
        A.red.delete(s)
        return obj.reply('Deleted spam #%s!' % obj.m[1])
    if 'spam' in obj.kwargs:
        A.callHook('core_spam_push', int(obj.m[1]))
    A.red.hset(s, 'data', json.dumps(obj.sess['data']))
    obj.reply('Edited spam #%s!' % obj.m[1])
Esempio n. 12
0
def cmdMsg(obj):
    if len(obj.m) == 1: return obj.usage()
    if not 'msg' in obj.kwargs: return obj.reply('You must specify a message to send!')
    obj.sess['msg'] = obj.kwargs.get('msg', '')
    obj.sess['chan'] = [i.strip() for i in obj.kwargs.get('chan', obj.dest).split(',')]
    obj.sess['nick'] = obj.kwargs.get('nick', True)
    obj.sess['force'] = obj.kwargs.get('force', False)
    if not obj.sess['msg'].strip(' '): return obj.reply('You cannot send an empty message!')
    if obj.sess['nick']: obj.sess['msg'] = "%s: %s" % (obj.nick, obj.sess['msg'])
    else: obj.msg = obj.sess['msg']
    if obj.sess['chan'] == ['*']: pass #@TODO do this
    elif obj.sess['chan']:
        fails = []
        for i in obj.sess['chan']:
            i = i.replace('#', '')
            if A.validChan(obj.nid, i): obj.send(i, obj.sess['msg'])
            elif obj.sess['force']: pass
            else: fails.append(i)
        if len(fails):
            obj.reply('Failed sending to the following channels: %s' % ', '.join(fails))
Esempio n. 13
0
def cmdReload(obj):
    obj.reply('Reloading plugins...')
    A.reloadPlugins(obj.reply, 'Reloaded all plugins!')