Exemple #1
0
def on_chatevent(bn, d):
    if d.event == bnetprotocol.EID_WHISPER:
        if str(d.message).split(' ')[0] == config.config['gamehost'][
                'bnet_prefix'] + config.config['gamehost']['bnet_command']:
            bn.send_packet(
                bnetprotocol.SEND_SID_CHATCOMMAND('/w %s TODO: host game' %
                                                  (d.user)))
def spam_loop(bn, d):
    if parsed_settings[bn.id]['ignore']:
        return

    while True:
        eventlet.sleep(parsed_settings[bn.id]['interval'])
        gamelist = []
        counter = 0
        for k in friendstalk.friends[friendstalk.bn_to_pool(bn)]:
            v = friendstalk.friends[friendstalk.bn_to_pool(bn)][k]
            if v.general == bnetprotocol.FRIENDLOCATION_PUB:
                gamelist.append(v.specific)
        if len(gamelist) > 0:
            msg = 'Games: %s' % ', '.join(gamelist)
            bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND('/me %s' % msg))
        #DEBUG
        else:
            msg = 'No Games'
            bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND('/me %s' % msg))
Exemple #3
0
def message_received(bn, d):
    if parsed_settings[bn.id]['ignore']:
        return

    if d.event == bnetprotocol.EID_TALK:
        msg_list = str(d.message).split(' ', 1)
        try:
            command, payload = msg_list
        except ValueError:
            command = msg_list[0]
            payload = ''
        if command == parsed_settings[bn.id]['command'] and len(payload) > 0 \
           and clantrack.get_clanmember_rank(bn, str(d.user)) >= int(parsed_settings[bn.id]['minrank']):
            onlinenames = clantrack.get_online_clanmembers(bn)
            pool = clantrack.bn_to_pool(bn)
            if spam_locks.get(pool, False) == False:
                spam_locks[pool] = True
                bn_pool = clantrack.list_of_bnet_objects(pool)
                bn_count = len(bn_pool)
                bn_i = 0
                current_bn = bn_pool[0]
                current_bn.send_packet(
                    bnetprotocol.SEND_SID_CHATCOMMAND(
                        'Adding %d to Clan Notify List' % len(onlinenames)))

                for i in onlinenames:
                    current_bn, bn_i = next_in_circular_list(bn_pool, bn_i)
                    current_bn.send_packet(
                        bnetprotocol.SEND_SID_CHATCOMMAND('/w %s %s' %
                                                          (i, payload)))
                    atomic_debug('whispering to %s using %s' %
                                 (i, repr(current_bn)))
                    eventlet.sleep(3. / bn_count)

                current_bn, bn_i = next_in_circular_list(bn_pool, bn_i)
                current_bn.send_packet(
                    bnetprotocol.SEND_SID_CHATCOMMAND(
                        ', '.join(clantrack.clantags_in_pool(pool)) +
                        ' Done sending messages.'))
                spam_locks[pool] = False
            else:
                atomic_debug('pool %d is spamlocked' % pool)
Exemple #4
0
def message_received(bn, d):
	if d.event == bnetprotocol.EID_TALK:
		msg_list = str(d.message).split(' ', 1)
		try:
			command, payload = msg_list
		except ValueError:
			command = msg_list[0]
			payload = ''
		if command == '.join' and len(payload) > 0:
			'''if str(d.message).split(' ')[0] == settings['trigger'] + 'join':'''
			bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND('/join %s' % (payload)))
def message_received(bn, d):
    if parsed_settings[bn.id]['ignore']:
        return

    if d.event == bnetprotocol.EID_TALK:
        msg_list = str(d.message).split(' ', 1)
        try:
            command, payload = msg_list
        except ValueError:
            command = msg_list[0]
            payload = ''
        if command == parsed_settings[bn.id]['command'] and str(
                d.user).lower() in parsed_settings[bn.id]['admins']:
            parsed_settings[bn.id]['msg'] = payload
            bn.send_packet(
                bnetprotocol.SEND_SID_CHATCOMMAND(b'Greeting changed.'))

    elif d.event == bnetprotocol.EID_JOIN:
        bn.send_packet(
            bnetprotocol.SEND_SID_CHATCOMMAND(b'/w ' + d.user + ' ' +
                                              parsed_settings[bn.id]['msg']))
Exemple #6
0
def message_received(bn, d):
    if parsed_settings[bn.id]['ignore']:
        return

    if d.event == bnetprotocol.EID_TALK:
        if str(d.message).split(' ')[0] == parsed_settings[bn.id]['command'] \
          and clantrack.get_clanmember_rank(bn, str(d.user)) >= int(parsed_settings[bn.id]['minrank']):
            onlinenames = clantrack.get_online_clanmembers(bn)
            liststring = ', '.join(onlinenames)
            message = ', '.join(
                clantrack.clantags_in_pool(
                    clantrack.bn_to_pool(bn))) + ' (' + str(
                        len(onlinenames)) + '): ' + liststring
            bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND(message))
Exemple #7
0
def claninvitation_feedback(bn, d):
    message = ''
    if d.result == 0:
        message = '%s is now in %s.' % (str(
            invitations[d.cookie]), clantrack.clantags[bn.id])
    elif d.result == 4:
        message = '%s refused the invitation to %s.' % (str(
            invitations[d.cookie]), clantrack.clantags[bn.id])
    elif d.result == 5:
        message = 'An error occured while inviting %s to %s.' % (str(
            invitations[d.cookie]), clantrack.clantags[bn.id])
    elif d.result == 9:
        message = '%s could not join %s because it is full.' % (str(
            invitations[d.cookie]), clantrack.clantags[bn.id])

    del invitations[d.cookie]

    bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND(message))
Exemple #8
0
def message_received(bn, d):
	if d.event == bnetprotocol.EID_TALK:
		if str(d.message).split(' ')[0] == settings['trigger'] + 'slapme':
			bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND('/me ударил %s' % (d.user)))
Exemple #9
0
def send_fl(bn, d):
    bn.send_packet(bnetprotocol.SEND_SID_CHATCOMMAND('/f l'))