Example #1
0
def answer(perg):
    key = question.genKeyWords(perg)
    files = retrieve(key)
    if files is None:
        return u"Eu não tenho ideia!"
    else:
        data_title = retrieve_by_filename(key)
        res_t = inferencer.search(key, data_title)
        if res_t == 0:
            data_file = retrieve_equal_files(key)
            res_f = inferencer.search(key, data_file)
            if res_f == 0:
                data_commom = retrieve_commom(key)
                res_c = inferencer.search(key, data_commom)
                if res_c == 0:
                    return error_message()
                else:
                    user.insert(perg, len(res_c))
                    return return_data(res_c)
            else:
                user.insert(perg, len(res_f))
                return return_data(res_f)
        else:
            user.insert(perg, len(res_t))
            return return_data(res_t)
Example #2
0
def set_cooldown(channel, mode, cooldown, current_channel):
    if mode == 'global':
        try:
            db(opt.CHANNELS).update_one_by_name(
                channel, {'$set': {
                    'global_cooldown': cooldown
                }})
        except Exception as e:
            queue_message_to_one(messages.error_message(e), current_channel)
    elif mode == 'user':
        try:
            db(opt.CHANNELS).update_one_by_name(
                channel, {'$set': {
                    'user_cooldown': cooldown
                }})
        except Exception as e:
            queue_message_to_one(messages.error_message(e), current_channel)
    else:
        queue_message_to_one(messages.set_cooldown_error, current_channel)
Example #3
0
def set_events(channel, mode, current_channel):
    try:
        if mode == 'off' and db(opt.CHANNELS).find_one({'name': channel
                                                        })['raid_events'] == 1:
            queue_message_to_one(
                messages.set_event_message('disabled', channel), channel)
            db(opt.CHANNELS).update_one_by_name(channel,
                                                {'$set': {
                                                    'raid_events': 0
                                                }})

        elif mode == 'on' and db(opt.CHANNELS).find_one(
            {'name': channel})['raid_events'] == 0:
            queue_message_to_one(
                messages.set_event_message('enabled', channel), channel)
            db(opt.CHANNELS).update_one_by_name(channel,
                                                {'$set': {
                                                    'raid_events': 1
                                                }})

    except Exception as e:
        queue_message_to_one(messages.error_message(e), current_channel)
Example #4
0
                                    except IndexError:
                                        util.queue_message_to_one(messages.add_text_error, channel)

                            if params[0] == 'add':
                                if tags.get('admin') == 1:
                                    try:
                                        util.join_channel(channel, params[1], float(params[2]), float(params[3]))
                                    except IndexError:
                                        if len(params) == 3:
                                            util.join_channel(channel, params[1], float(params[2]), 0)
                                        elif len(params) == 2:
                                            util.join_channel(channel, params[1], 2.5, 0)
                                        else:
                                            util.queue_message_to_one(messages.add_channel_error, channel)
                                    except ValueError as e:
                                        util.queue_message_to_one(messages.error_message(e), channel)

                            if params[0] == 'part':
                                if tags.get('admin') == 1:
                                    try:
                                        util.part_channel(params[1])
                                    except IndexError:
                                        util.queue_message_to_one(messages.part_channel_error, channel)

                                elif tags.get('moderator') == 1:
                                    try:
                                        if params[1] == display_name.casefold():
                                            util.part_channel(params[1])
                                    except IndexError:
                                        util.part_channel(display_name.casefold())
Example #5
0
def run_exec(code, channel):
    try:
        exec(code)
    except Exception as e:
        queue_message_to_one(messages.error_message(e), channel)
Example #6
0
def run_eval(expression, channel):
    try:
        queue_message_to_one(str(eval(expression)), channel)
    except Exception as e:
        queue_message_to_one(messages.error_message(e), channel)