- Subscribe less greedily. We'll need to ensure we subscribe when we need them now!

This commit is contained in:
trigg 2020-10-17 17:06:34 +00:00
parent 73be243bc0
commit 1bd27b2506
6 changed files with 25 additions and 5 deletions

View file

@ -35,6 +35,7 @@ class DiscordConnector:
self.last_connection = ""
self.text = []
self.authed = False
self.last_text_channel = None
def get_access_token_stage1(self):
self.ws.send("{\"cmd\":\"AUTHORIZE\",\"args\":{\"client_id\":\"%s\",\"scopes\":[\"rpc\",\"messages.read\"],\"prompt\":\"none\"},\"nonce\":\"deadbeef\"}" % (
@ -262,8 +263,8 @@ class DiscordConnector:
if channel["type"] == 2:
self.req_channel_details(channel["id"])
self.check_guilds()
self.sub_all_voice_guild(j["nonce"])
self.sub_all_text_guild(j["nonce"])
#self.sub_all_voice_guild(j["nonce"])
#self.sub_all_text_guild(j["nonce"])
return
elif j["cmd"] == "SUBSCRIBE":
return
@ -308,6 +309,8 @@ class DiscordConnector:
u"%s: %s" % (guild["name"], channels))
self.sub_server()
self.find_user()
if self.last_text_channel:
self.sub_text_channel(self.last_text_channel)
def on_error(self, error):
logging.error("ERROR : %s" % (error))
@ -430,6 +433,12 @@ class DiscordConnector:
return True
return True
def start_listening_text(self, ch):
if self.ws:
self.sub_text_channel(ch)
else:
self.last_text_channel = ch
def connect(self):
if self.ws:
return

View file

@ -35,6 +35,7 @@ class Discover:
self.connection = DiscordConnector(
self.settings.text_settings, self.settings.voice_settings,
self.text_overlay, self.voice_overlay)
self.settings.text_settings.add_connector(self.connection)
self.connection.connect()
GLib.timeout_add((1000 / 60), self.connection.do_read)
self.rpc_file = rpc_file

View file

@ -19,6 +19,7 @@ class MainSettingsWindow(Gtk.Window):
self.text_overlay = text_overlay
self.voice_overlay = voice_overlay
self.set_title("Discover Overlay Configuration")
# Create
nb = Gtk.Notebook()

View file

@ -31,6 +31,7 @@ class TextOverlayWindow(OverlayWindow):
self.imgList = []
self.imgFinder = re.compile(r"`")
self.set_title("Discover Text")
def set_text_time(self, t):
self.text_time = t

View file

@ -22,6 +22,11 @@ class TextSettingsWindow(SettingsWindow):
self.ignore_channel_change = False
self.create_gui()
def add_connector(self, conn):
self.connector = conn
if self.channel:
self.connector.start_listening_text(self.channel)
def present(self):
self.show_all()
if not self.floating:
@ -307,7 +312,9 @@ class TextSettingsWindow(SettingsWindow):
def change_channel(self, button):
if self.ignore_channel_change:
return
c = self.channel_lookup[button.get_active()]
self.connector.start_listening_text(c)
self.channel = c
self.save_config()

View file

@ -36,9 +36,10 @@ class VoiceOverlayWindow(OverlayWindow):
self.users_to_draw = []
self.connected = False
self.force_location()
self.def_avatar = get_surface(self.recv_avatar,
"https://cdn.discordapp.com/embed/avatars/3.png",
'def', self.avatar_size)
get_surface(self.recv_avatar,
"https://cdn.discordapp.com/embed/avatars/3.png",
'def', self.avatar_size)
self.set_title("Discover Voice")
def set_bg(self, bg):
self.norm_col = bg