Exemple #1
0
def pull_messages(channels):
    global cursors

    if not in_game:
        return

    for channel in channels:
        # Initialize if not present
        if channel["id"] not in cursors:
            cursors[channel["id"]] = channel["last_message_id"]
            continue

        r = requests.get(API_ENDPOINT + "/channels/%s/messages?after=%s" % (channel["id"], \
                                                                            cursors[channel["id"]]), \
                                                                            auth=auth)
        if r.status_code != 200:
            return
        messages = r.json()

        for message in messages:
            author = message["author"]
            ingame_notification = "(#%s) %s: %s" % (channel["name"], \
                                                    author["username"], \
                                                    message["content"])
            ro_client.print_in_chat(ingame_notification, 0xFFFFFF, 0)
            cursors[channel["id"]] = message["id"]
Exemple #2
0
def on_irc_message(server, event):
    username = event.source.nick
    message = event.arguments[0]
    channel = event.target
    ingame_notification = "(%s) %s: %s" % (channel, username, message)

    ro_client.print_in_chat(ingame_notification, 0xFFFFFF, 0)
Exemple #3
0
def on_irc_message(server, event):
    if current_mode == Mode.Game:
        username = event.source.nick
        message = event.arguments[0]
        channel = event.target
        ingame_notification = "(%s) %s: %s" % (channel, username, message)

        ro_client.print_in_chat(ingame_notification, COLOR_IRC_MSG, 0)
Exemple #4
0
def on_tick():
    if in_game:
        hp_percent = client.get_hp() / client.get_max_hp()
        sp_percent = client.get_sp() / client.get_max_sp()

        if hp_percent < HP_MIN_PERCENT:
            if client.use_item(RED_SLIM_POTION):
                client.print_in_chat("Using a HP potion", 0xFFFFFF, 0)
        elif sp_percent < SP_MIN_PERCENT:
            if client.use_item(BLUE_POTION):
                client.print_in_chat("Using a SP potion", 0xFFFFFF, 0)
Exemple #5
0
def on_talktype(chat_buffer):
    if current_mode == Mode.Game:
        if chat_buffer.find("/irc ") == 0:
            parts = chat_buffer.split(' ', 2)

            if len(parts) != 3:
                ro_client.print_in_chat("Invalid arguments.", COLOR_ERROR, 0)
                return
            elif parts[1] not in CHANNELS:
                ro_client.print_in_chat("Incorrect channel.", COLOR_ERROR, 0)
                return

            server.privmsg(parts[1], parts[2])
            ingame_notification = "(%s) %s: %s" % (parts[1].lower(), NICKNAME,\
                                                   parts[2])
            ro_client.print_in_chat(ingame_notification, COLOR_IRC_MSG, 0)
Exemple #6
0
def on_enter_ingame():
    global server

    server.join(CHANNEL)
    ro_client.print_in_chat("IRC Plugin: Now listening in %s" % CHANNEL,
                            0xFFFFFF, 0)
Exemple #7
0
def printf(string):
    client.print_in_chat(string, 0xFFFFFF, 0)