weechat-matrix: Handle the case where our clients gets soft-logged out.

This commit is contained in:
Damir Jelić 2019-09-10 15:26:54 +02:00
parent 2aa70c7ead
commit dc34a5bef9
4 changed files with 18 additions and 5 deletions

View file

@ -112,7 +112,7 @@ def matrix_bar_item_buffer_modes(data, item, window, buffer, extra_info):
and server.client.room_contains_unverified(room.room_id)):
modes.append(G.CONFIG.look.encryption_warning_sign)
if not server.connected:
if not server.connected or not server.client.logged_in:
modes.append(G.CONFIG.look.disconnect_sign)
if room_buffer.backlog_pending or server.busy:

View file

@ -96,6 +96,10 @@ def room_buffer_input_cb(server_name, buffer, input_data):
room_buffer.error("You are not connected to the server")
return W.WEECHAT_RC_ERROR
if not server.client.logged_in:
room_buffer.error("You are not logged in.")
return W.WEECHAT_RC_ERROR
data = W.string_input_for_buffer(input_data)
if not data:

View file

@ -933,6 +933,10 @@ def matrix_me_command_cb(data, buffer, args):
W.prnt(server.server_buffer, message)
return W.WEECHAT_RC_ERROR
if not server.client.logged_in:
room_buffer.error("You are not logged in.")
return W.WEECHAT_RC_ERROR
room_buffer = server.find_room_from_ptr(buffer)
if not args:
@ -1817,6 +1821,10 @@ def matrix_send_anyways_cb(data, buffer, args):
room_buffer.error("Server is diconnected")
break
if not server.client.logged_in:
room_buffer.error("You are not logged in.")
return W.WEECHAT_RC_ERROR
if not room_buffer.last_message:
room_buffer.error("No previously sent message found.")
break

View file

@ -862,7 +862,7 @@ class MatrixServer(object):
be sent.
event_id(str): the event id where to set the marker
"""
if not self.connected:
if not self.connected or not self.client.logged_in:
return
_, request = self.client.room_read_markers(
@ -878,7 +878,7 @@ class MatrixServer(object):
room_buffer(RoomBuffer): the room for which the typing notice needs
to be sent.
"""
if not self.connected:
if not self.connected or not self.client.logged_in:
return
input = room_buffer.weechat_buffer.input
@ -1098,8 +1098,9 @@ class MatrixServer(object):
self.send_or_queue(request)
def get_joined_members(self, room_id):
if not self.connected:
if not self.connected or not self.client.logged_in:
return
if room_id in self.member_request_list:
return
@ -1836,7 +1837,7 @@ def matrix_timer_cb(server_name, remaining_calls):
server.reconnect()
return W.WEECHAT_RC_OK
if not server.connected:
if not server.connected or not server.client.logged_in:
return W.WEECHAT_RC_OK
# check lag, disconnect if it's too big