completion: Add a room name completion.
This is meant to be used as another default_template for the global weechat completion.
This commit is contained in:
parent
6ddf63093a
commit
75b2b85626
2 changed files with 23 additions and 1 deletions
3
main.py
3
main.py
|
@ -63,7 +63,8 @@ from matrix.completion import (init_completion, matrix_command_completion_cb,
|
|||
matrix_server_command_completion_cb,
|
||||
matrix_server_completion_cb,
|
||||
matrix_user_completion_cb,
|
||||
matrix_own_devices_completion_cb)
|
||||
matrix_own_devices_completion_cb,
|
||||
matrix_room_completion_cb)
|
||||
from matrix.config import (MatrixConfig, config_log_category_cb,
|
||||
config_log_level_cb, config_server_buffer_cb,
|
||||
matrix_config_reload_cb, config_pgup_cb)
|
||||
|
|
|
@ -280,6 +280,20 @@ def matrix_user_completion_cb(data, completion_item, buffer, completion):
|
|||
return W.WEECHAT_RC_OK
|
||||
|
||||
|
||||
@utf8_decode
|
||||
def matrix_room_completion_cb(data, completion_item, buffer, completion):
|
||||
"""Completion callback for matrix room names."""
|
||||
for server in SERVERS.values():
|
||||
for room_buffer in server.room_buffers.values():
|
||||
name = room_buffer.weechat_buffer.short_name
|
||||
|
||||
W.hook_completion_list_add(
|
||||
completion, name, 0, W.WEECHAT_LIST_POS_SORT
|
||||
)
|
||||
|
||||
return W.WEECHAT_RC_OK
|
||||
|
||||
|
||||
def init_completion():
|
||||
W.hook_completion(
|
||||
"matrix_server_commands",
|
||||
|
@ -343,3 +357,10 @@ def init_completion():
|
|||
"matrix_own_devices_completion_cb",
|
||||
"",
|
||||
)
|
||||
|
||||
W.hook_completion(
|
||||
"matrix_rooms",
|
||||
"Matrix room name completion",
|
||||
"matrix_room_completion_cb",
|
||||
"",
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue