Matrix server command refactor.
This commit is contained in:
parent
41a346d73b
commit
1bc6a6b1ed
1 changed files with 257 additions and 250 deletions
|
@ -1113,7 +1113,7 @@ def matrix_command_help(args):
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
|
|
||||||
|
|
||||||
def matrix_server_command(command, args):
|
def matrix_server_command_listfull(args):
|
||||||
def get_value_string(value, default_value):
|
def get_value_string(value, default_value):
|
||||||
if value == default_value:
|
if value == default_value:
|
||||||
if not value:
|
if not value:
|
||||||
|
@ -1127,16 +1127,6 @@ def matrix_server_command(command, args):
|
||||||
|
|
||||||
return value_string
|
return value_string
|
||||||
|
|
||||||
def list_servers(args):
|
|
||||||
if SERVERS:
|
|
||||||
W.prnt("", "\nAll matrix servers:")
|
|
||||||
for server in SERVERS:
|
|
||||||
W.prnt("", " {color}{server}".format(
|
|
||||||
color=W.color("chat_server"),
|
|
||||||
server=server
|
|
||||||
))
|
|
||||||
|
|
||||||
def list_full_servers(args):
|
|
||||||
for server_name in args:
|
for server_name in args:
|
||||||
if server_name not in SERVERS:
|
if server_name not in SERVERS:
|
||||||
continue
|
continue
|
||||||
|
@ -1209,7 +1199,8 @@ def matrix_server_command(command, args):
|
||||||
|
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
|
|
||||||
def delete_server(args):
|
|
||||||
|
def matrix_server_command_delete(args):
|
||||||
for server_name in args:
|
for server_name in args:
|
||||||
if check_server_existence(server_name, SERVERS):
|
if check_server_existence(server_name, SERVERS):
|
||||||
server = SERVERS[server_name]
|
server = SERVERS[server_name]
|
||||||
|
@ -1246,7 +1237,8 @@ def matrix_server_command(command, args):
|
||||||
|
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
|
|
||||||
def add_server(args):
|
|
||||||
|
def matrix_server_command_add(args):
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
message = ("{prefix}matrix: Too few arguments for command "
|
message = ("{prefix}matrix: Too few arguments for command "
|
||||||
"\"/matrix server add\" (see the help for the command: "
|
"\"/matrix server add\" (see the help for the command: "
|
||||||
|
@ -1376,22 +1368,33 @@ def matrix_server_command(command, args):
|
||||||
ncolor=W.color("reset"))
|
ncolor=W.color("reset"))
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
|
|
||||||
|
|
||||||
|
def matrix_server_command(command, args):
|
||||||
|
def list_servers(args):
|
||||||
|
if SERVERS:
|
||||||
|
W.prnt("", "\nAll matrix servers:")
|
||||||
|
for server in SERVERS:
|
||||||
|
W.prnt("", " {color}{server}".format(
|
||||||
|
color=W.color("chat_server"),
|
||||||
|
server=server
|
||||||
|
))
|
||||||
|
|
||||||
# TODO the argument for list and listfull is used as a match word to
|
# TODO the argument for list and listfull is used as a match word to
|
||||||
# find/filter servers, we're currently match exactly to the whole name
|
# find/filter servers, we're currently match exactly to the whole name
|
||||||
if command == 'list':
|
if command == 'list':
|
||||||
list_servers(args)
|
list_servers(args)
|
||||||
|
|
||||||
elif command == 'listfull':
|
elif command == 'listfull':
|
||||||
list_full_servers(args)
|
matrix_server_command_listfull(args)
|
||||||
|
|
||||||
elif command == 'add':
|
elif command == 'add':
|
||||||
add_server(args)
|
matrix_server_command_add(args)
|
||||||
|
|
||||||
elif command == 'delete':
|
elif command == 'delete':
|
||||||
delete_server(args)
|
matrix_server_command_delete(args)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Unknown server command")
|
message = ("{prefix}matrix: Error: unknown matrix server command, "
|
||||||
|
"\"{command}\" (type /matrix help server for help)").format(
|
||||||
|
prefix=W.prefix("error"),
|
||||||
|
command=command)
|
||||||
|
W.prnt("", message)
|
||||||
|
|
||||||
|
|
||||||
@utf8_decode
|
@utf8_decode
|
||||||
|
@ -1439,7 +1442,11 @@ def matrix_command_cb(data, buffer, args):
|
||||||
matrix_command_help(args)
|
matrix_command_help(args)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Unknown command")
|
message = ("{prefix}matrix: Error: unknown matrix command, "
|
||||||
|
"\"{command}\" (type /help matrix for help)").format(
|
||||||
|
prefix=W.prefix("error"),
|
||||||
|
command=command)
|
||||||
|
W.prnt("", message)
|
||||||
|
|
||||||
return W.WEECHAT_RC_OK
|
return W.WEECHAT_RC_OK
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue