Merge branch 'master' into text-channels-by-server
This commit is contained in:
commit
fb7003dc8f
8 changed files with 31 additions and 11 deletions
|
|
@ -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\"}" % (
|
||||
|
|
@ -62,6 +63,7 @@ class DiscordConnector:
|
|||
cn = self.channels[channel]['name']
|
||||
logging.info(
|
||||
"Joined room: %s" % (cn))
|
||||
self.sub_voice_channel(channel)
|
||||
self.current_voice = channel
|
||||
if need_req:
|
||||
self.req_channel_details(channel)
|
||||
|
|
@ -200,7 +202,7 @@ class DiscordConnector:
|
|||
self.set_in_room(j["data"]["user"]["id"], False)
|
||||
if j["data"]["user"]["id"] == self.user["id"]:
|
||||
self.in_room = []
|
||||
self.sub_all_voice()
|
||||
#self.sub_all_voice()
|
||||
else:
|
||||
un = j["data"]["user"]["username"]
|
||||
elif j["evt"] == "SPEAKING_START":
|
||||
|
|
@ -262,8 +264,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 +310,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))
|
||||
|
|
@ -432,6 +436,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ class OverlayWindow(Gtk.Window):
|
|||
def __init__(self):
|
||||
Gtk.Window.__init__(self, type=self.detect_type())
|
||||
screen = self.get_screen()
|
||||
screen_type = "%s" % (screen)
|
||||
self.set_size_request(50, 50)
|
||||
|
||||
self.connect('draw', self.draw)
|
||||
|
|
@ -27,7 +26,6 @@ class OverlayWindow(Gtk.Window):
|
|||
self.compositing = False
|
||||
# Set RGBA
|
||||
screen = self.get_screen()
|
||||
screen_type = "%s" % (screen)
|
||||
visual = screen.get_rgba_visual()
|
||||
if not self.get_display().supports_input_shapes():
|
||||
logging.info(
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -96,7 +97,7 @@ class TextOverlayWindow(OverlayWindow):
|
|||
ret = "`"
|
||||
elif msg['type'] == 'inlineCode' or msg['type'] == 'codeBlock' or msg['type'] == 'blockQuote':
|
||||
ret = "<span font_family=\"monospace\" background=\"#0004\">%s</span>" % (
|
||||
msg['content'])
|
||||
self.make_line(msg['content']))
|
||||
elif msg['type'] == 'u':
|
||||
ret = "<u>%s</u>" % (self.make_line(msg['content']))
|
||||
elif msg['type'] == 'em':
|
||||
|
|
@ -110,7 +111,7 @@ class TextOverlayWindow(OverlayWindow):
|
|||
elif msg['type'] == 'br':
|
||||
ret = '\n'
|
||||
else:
|
||||
logging.warning("Unknown text type : %s" % (msg["type"]))
|
||||
logging.error("Unknown text type : %s" % (msg["type"]))
|
||||
return ret
|
||||
|
||||
def recv_attach(self, id, pix):
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class TextSettingsWindow(SettingsWindow):
|
|||
self.ignore_guild_change = False
|
||||
self.create_gui()
|
||||
|
||||
|
||||
def update_channel_model(self):
|
||||
# potentially organize channels by their group/parent_id
|
||||
# https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
|
||||
|
|
@ -64,6 +65,11 @@ class TextSettingsWindow(SettingsWindow):
|
|||
idx += 1
|
||||
|
||||
|
||||
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:
|
||||
|
|
@ -371,7 +377,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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -25,7 +25,7 @@ setup(
|
|||
'websocket-client',
|
||||
'pyxdg',
|
||||
'requests',
|
||||
'python-pidfile',
|
||||
'python-pidfile>=3.0.0',
|
||||
'pillow',
|
||||
],
|
||||
entry_points={
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue