Skip to content

Commit

Permalink
twitch.py: eval client_id and token when used with secures
Browse files Browse the repository at this point in the history
  • Loading branch information
stacyharper committed Jun 20, 2024
1 parent f27e2c0 commit c2a46e6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
# added setting 'plugins.var.python.twitch.notice_notify_block'
# added setting 'plugins.var.python.twitch.client_id'
#
# 2024-06-20, stacyharper
# v0.8: eval client_id and token expressions. Usefull when used with weechat secures values.
# 2019-09-21, mumixam
# v0.7: updated script to use current api
# 2019-03-03,
Expand Down Expand Up @@ -552,6 +554,8 @@ def config_setup():
hlist = []
cidv = weechat.config_get_plugin(option)
tokv = weechat.config_get_plugin('token')
if tokv[:6] == "${sec.":
tokv = weechat.string_eval_expression(tokv, {}, {}, {})
if cidv:
hlist.append('Client-ID: '+cidv)
if tokv:
Expand All @@ -562,6 +566,8 @@ def config_setup():
hlist = []
cidv = weechat.config_get_plugin('client_id')
tokv = weechat.config_get_plugin(option)
if tokv[:6] == "${sec.":
tokv = weechat.string_eval_expression(tokv, {}, {}, {})
if tokv:
hlist.append('Authorization: Bearer '+tokv)
if cidv:
Expand Down Expand Up @@ -592,6 +598,8 @@ def config_change(pointer, name, value):
curlopt['httpheader'] = x + '\n' + "Client-ID: " + value
break
if option == 'token':
if value[:6] == "${sec.":
value = weechat.string_eval_expression(value, {}, {}, {})
for x in curlopt['httpheader'].split('\n'):
if x.startswith('Client-ID:'):
curlopt['httpheader'] = x + '\n' + "Authorization: Bearer " + value
Expand Down

0 comments on commit c2a46e6

Please sign in to comment.