~reedwade/wee-matter

04a0a6c7450d419e1fe3e514005e68ccb9e5ad08 — Stacy Harper 2 months ago 1f9984b
Add a completion for all configured server names
5 files changed, 14 insertions(+), 9 deletions(-)

M main.py
M wee_matter/commands.py
M wee_matter/config.py
M wee_matter/http.py
M wee_matter/server.py
M main.py => main.py +3 -2
@@ 6,7 6,7 @@ from wee_matter.room import (handle_multiline_message_cb, room_input_cb,
                             channel_click_cb, hydrate_outdated_buffers)


from wee_matter.server import server_completion_cb
from wee_matter.server import connected_server_completion_cb

from wee_matter.commands import (matter_command_cb, reply_command_cb,
                                 react_command_cb, unreact_command_cb,


@@ 20,7 20,8 @@ from wee_matter.http import (singularity_cb, buffered_response_cb,

from wee_matter.config import (config_reload_cb, server_section_read_cb,
                               server_section_write_cb, server_section_write_default_cb,
                               server_section_create_option_cb, server_section_delete_option_cb)
                               server_section_create_option_cb, server_section_delete_option_cb,
                               server_completion_cb)
import wee_matter

WEECHAT_SCRIPT_NAME = "wee_matter"

M wee_matter/commands.py => wee_matter/commands.py +3 -2
@@ 206,8 206,8 @@ def setup_commands():
        # Completions
        (
            "server add ||"
            "connect ||"
            "disconnect %(mattermost_server_commands) ||"
            "connect %(mattermost_server_commands) ||"
            "disconnect %(mattermost_connected_server_commands) ||"
            "command %(mattermost_slash_commands) ||"
        ),
        "matter_command_cb",


@@ 224,4 224,5 @@ def setup_commands():
    weechat.hook_completion("irc_channels", "complete channels for mattermost", "channel_completion_cb", "")
    weechat.hook_completion("irc_privates", "complete dms/mpdms for mattermost", "private_completion_cb", "")
    weechat.hook_completion("mattermost_server_commands", "complete server names for mattermost", "server_completion_cb", "")
    weechat.hook_completion("mattermost_connected_server_commands", "connected server names for mattermost", "connected_server_completion_cb", "")
    weechat.hook_completion("mattermost_slash_commands", "complete mattermost slash commands", "slash_command_completion_cb", "")

M wee_matter/config.py => wee_matter/config.py +5 -0
@@ 16,6 16,11 @@ server_keys = {

server_names = []

def server_completion_cb(data, completion_item, current_buffer, completion):
    for server_name in server_names:
        weechat.hook_completion_list_add(completion, server_name, 0, weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK

def download_location():
    return weechat.config_get_plugin("download_location")


M wee_matter/http.py => wee_matter/http.py +2 -4
@@ 14,10 14,8 @@ from wee_matter.file import file_get_cb

from wee_matter.server import (connect_server_cb, connect_server_teams_cb,
                               connect_server_team_channels_cb, disconnect_server_cb,
                               connect_server_users_cb, server_completion_cb,
                               connect_server_team_channel_cb, connect_server_team_cb,
                               new_user_cb)

                               connect_server_users_cb, connect_server_team_channel_cb,
                               connect_server_team_cb, new_user_cb)

def build_file_url(file_id, server):
    return wee_matter.server.server_root_url(server) + "/api/v4/files/" + file_id

M wee_matter/server.py => wee_matter/server.py +1 -1
@@ 121,7 121,7 @@ def create_user_from_user_data(user_data, server):
        color= color_for_username(user_data["username"]),
    )

def server_completion_cb(data, completion_item, current_buffer, completion):
def connected_server_completion_cb(data, completion_item, current_buffer, completion):
    servers = get_servers()
    for server_name in servers:
        weechat.hook_completion_list_add(completion, server_name, 0, weechat.WEECHAT_LIST_POS_SORT)