Skip to content

Commit d30cec4

Browse files
fix(discord): update idle event & invidious urls
1 parent ec36d6a commit d30cec4

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

.github/workflows/issues.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Add to Clipshot project
1212
if: |
1313
contains(github.event.issue.body, '[x] `clipshot.lua`')
14-
uses: alex-page/github-project-automation-plus@v0.1.0
14+
uses: alex-page/github-project-automation-plus@v0.5.1
1515
with:
1616
project: Clipshot
1717
column: To do
@@ -20,7 +20,7 @@ jobs:
2020
- name: Add to Misc project
2121
if: |
2222
contains(github.event.issue.body, '[x] `misc.lua`')
23-
uses: alex-page/github-project-automation-plus@v0.1.0
23+
uses: alex-page/github-project-automation-plus@v0.5.1
2424
with:
2525
project: Misc
2626
column: To do
@@ -29,7 +29,7 @@ jobs:
2929
- name: Add to Open Dialog (KDialog) project
3030
if: |
3131
contains(github.event.issue.body, '[x] `open-dialog/kdialog.lua`')
32-
uses: alex-page/github-project-automation-plus@v0.1.0
32+
uses: alex-page/github-project-automation-plus@v0.5.1
3333
with:
3434
project: Open Dialog (KDialog)
3535
column: To do
@@ -38,7 +38,7 @@ jobs:
3838
- name: Add to Open Dialog (Zenity) project
3939
if: |
4040
contains(github.event.issue.body, '[x] `open-dialog/zenity.lua`')
41-
uses: alex-page/github-project-automation-plus@v0.1.0
41+
uses: alex-page/github-project-automation-plus@v0.5.1
4242
with:
4343
project: Open Dialog (Zenity)
4444
column: To do
@@ -47,7 +47,7 @@ jobs:
4747
- name: Add to Open Dialog (PowerShell) project
4848
if: |
4949
contains(github.event.issue.body, '[x] `open-dialog/powershell.lua`')
50-
uses: alex-page/github-project-automation-plus@v0.1.0
50+
uses: alex-page/github-project-automation-plus@v0.5.1
5151
with:
5252
project: Open Dialog (PowerShell)
5353
column: To do
@@ -56,7 +56,7 @@ jobs:
5656
- name: Add to Discord project
5757
if: |
5858
contains(github.event.issue.body, '[x] `discord.lua`')
59-
uses: alex-page/github-project-automation-plus@v0.1.0
59+
uses: alex-page/github-project-automation-plus@v0.5.1
6060
with:
6161
project: Discord
6262
column: To do

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
jobs:
66
luacheck:
7-
runs-on: ubuntu-18.04
7+
runs-on: ubuntu-latest
88
strategy:
99
matrix:
1010
lua:
@@ -15,13 +15,13 @@ jobs:
1515
- ver: luajit-2.0.5
1616
std: luajit
1717
steps:
18-
- uses: actions/checkout@master
18+
- uses: actions/checkout@v2
1919
name: Checkout repository
20-
- uses: leafo/gh-actions-lua@v5
20+
- uses: leafo/gh-actions-lua@v8.0.0
2121
name: Install lua - ${{matrix.lua.ver}}
2222
with:
2323
luaVersion: ${{matrix.lua.ver}}
24-
- uses: leafo/gh-actions-luarocks@v2
24+
- uses: leafo/gh-actions-luarocks@v4.0.0
2525
name: Install luarocks
2626
- name: Install luacheck
2727
run: luarocks install luacheck

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019-2020 ObserverOfTime
1+
Copyright (c) 2019-2021 ObserverOfTime
22

33
Permission to use, copy, modify, and/or distribute this software
44
for any purpose with or without fee is hereby granted.

discord.lua

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ require('mp.options').read_options(o, 'discord')
1212
function string.uuid()
1313
math.randomseed(mp.get_time() * 1e4)
1414
local tpl = 'XXXXXXXX-XXXX-4XXX-%xXXX-XXXXXXXXXXXX'
15-
return tpl:format(math.random(8, 0xb)):gsub('X', function(c)
15+
return tpl:format(math.random(8, 0xb)):gsub('X', function(_)
1616
return ('%x'):format(math.random(0, 0xf))
1717
end)
1818
end
1919

2020
function string:tohex()
2121
return self:gsub('.', function(c)
22-
return ('\\x%02x'):format(string.byte(c))
22+
return ('\\x%02x'):format(c:byte())
2323
end)
2424
end
2525

@@ -36,8 +36,8 @@ RPC = {
3636
if RPC.unix then
3737
local temp = os.getenv('XDG_RUNTIME_DIR')
3838
or os.getenv('TMPDIR')
39-
or os.getenv('TEMP')
4039
or os.getenv('TMP')
40+
or os.getenv('TEMP')
4141
or '/tmp'
4242
RPC.path = temp..'/discord-ipc-0'
4343
else
@@ -72,18 +72,18 @@ function RPC.pack(op, body)
7272
end
7373

7474
function RPC.unpack(body)
75+
local byte
7576
local op = 0
7677
local len = 0
7778
local iter = 1
78-
local byte = nil
7979
assert(body, 'empty body')
8080
for j = 1, 4 do
81-
byte = string.byte(body:sub(iter, iter))
81+
byte = body:sub(iter, iter):byte()
8282
op = op + byte * (2 ^ ((j - 1) * 8))
8383
iter = iter + 1
8484
end
8585
for j = 1, 4 do
86-
byte = string.byte(body:sub(iter, iter))
86+
byte = body:sub(iter, iter):byte()
8787
len = len + byte * (2 ^ ((j - 1) * 8))
8888
iter = iter + 1
8989
end
@@ -128,7 +128,7 @@ function RPC:recv(len)
128128
msg.error(data)
129129
return nil
130130
end
131-
assert(string.len(data) == len, 'incorrect data length')
131+
assert(data:len() == len, 'incorrect data length')
132132
msg.debug('received', data:tohex())
133133
return data
134134
end
@@ -198,7 +198,7 @@ function RPC:disconnect()
198198
end
199199
end
200200

201-
mp.register_event('idle', function()
201+
mp.register_event('idle-active', function()
202202
RPC.activity = {
203203
details = 'No file',
204204
state = nil,
@@ -229,14 +229,17 @@ mp.register_event('file-loaded', function()
229229
if path and path:find('^https?://') then
230230
if path:find('youtube%.com') or path:find('youtu%.be') then
231231
RPC.activity.assets.large_image = 'youtube'
232-
elseif path:find('invidio%.us') or path:find('yewtu%.be') then
233-
RPC.activity.assets.large_image = 'invidious'
234232
elseif path:find('twitch%.tv') then
235233
RPC.activity.assets.large_image = 'twitch'
236234
elseif path:find('twitter%.com') then
237235
RPC.activity.assets.large_image = 'twitter'
238-
elseif path:find('discordapp%.com') then
236+
elseif path:find('discordapp%.com') or
237+
path:find('discordapp%.net') then
239238
RPC.activity.assets.large_image = 'discord'
239+
elseif path:find('yewtu%.be') or
240+
path:find('invidious%.snopyta%.org') or
241+
path:find('vid%.mint%.lgbt') then
242+
RPC.activity.assets.large_image = 'invidious'
240243
else
241244
RPC.activity.assets.large_image = 'stream'
242245
end

0 commit comments

Comments
 (0)