weechat / scripts

Official scripts for WeeChat.
https://weechat.org/scripts/
232 stars 223 forks source link

twitch.py: eval client_id and token when used with secures #555

Closed stacyharper closed 5 months ago

stacyharper commented 5 months ago

Script info

Description

Checklist (new script)

Checklist (script update)

Checklist (script deletion)

flashcode commented 5 months ago

Hi,

Thanks for the PR.

The version 0.8 of the script was already released in past (current version is 0.9), and the script version must be updated as well.

Also could you please fill the form in the pull request? If possible, please at least contact the author of script or submit the PR upstream for validation by the author.

Thanks.

stacyharper commented 5 months ago

The version 0.8 of the script was already released in past (current version is 0.9), and the script version must be updated as well.

Ah my bad sorry! Updated the version.

Well, while looking at the upstream version, I notice that it already contains those eval expressions. Both seems to have slightly diverged.

While upstreaming it upstream, here is the produced diff:

diff --git a/twitch.py b/twitch.py
index eca1d82..17f7cdf 100644
--- a/twitch.py
+++ b/twitch.py
@@ -34,6 +34,8 @@
 #
 # # History:
 #
+# 2024-06-20, stacyharper
+#     v0.10: eval client_id and token expressions. Usefull when used with weechat secures values.
 # 2020-07-27,
 #     v0.9: added support for Oauth token to support twitch APIs requirement -mumixam
 #           fix bug for when api returns null for game_id -mas90
@@ -336,7 +338,7 @@ def twitch_clearchat(data, modifier, modifier_data, string):
     user = mp['text']
     channel = mp['channel']
     try:
-        tags = dict([s.split('=',1) for s in mp['tags'].split(';')])
+        tags = dict([s.split('=') for s in mp['tags'].split(';')])
     except:
         tags = ''
     buffer = weechat.buffer_search("irc", "%s.%s" % (server, channel))
@@ -377,7 +379,7 @@ def twitch_clearmsg(data, modifier, modifier_data, string):
     server = modifier_data
     channel = mp['channel']
     try:
-        tags = dict([s.split('=',1) for s in mp['tags'].split(';')])
+        tags = dict([s.split('=') for s in mp['tags'].split(';')])
     except:
         tags = ''
     buffer = weechat.buffer_search("irc", "%s.%s" % (server, channel))
@@ -452,7 +454,7 @@ def twitch_usernotice(data, modifier, server, string):
     buffer = weechat.buffer_search(
         "irc", "%s.%s" % (server, mp['channel']))
     if mp['tags']:
-        tags = dict([s.split('=',1) for s in mp['tags'].split(';')])
+        tags = dict([s.split('=') for s in mp['tags'].split(';')])
         msg = tags['system-msg'].replace('\s',' ')
         if mp['text']:
             msg += ' [Comment] '+mp['text']
@@ -496,7 +498,7 @@ def twitch_in_privmsg(data, modifier, server_name, string, prefix=''):
     if '#' + mp['nick'] == mp['channel']:
         return mp['message_without_tags'].replace(mp['nick'], '~' + mp['nick'], 1)

-    tags = dict([s.split('=',1) for s in mp['tags'].split(';')])
+    tags = dict([s.split('=') for s in mp['tags'].split(';')])
     if tags['user-type'] == 'mod':
         prefix += '@'
     if tags['subscriber'] == '1':
@@ -642,7 +644,7 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
         "    /set plugins.var.python.twitch.ssl_verify off\n"
         "\n\n"
         "  Required server settings:\n"
-        "    /server add twitch irc.chat.twitch.tv\n"
+        "    /server add twitch irc.twitch.tv\n"
         "    /set irc.server.twitch.capabilities \"twitch.tv/membership,twitch.tv/commands,twitch.tv/tags\"\n"
         "    /set irc.server.twitch.nicks \"My Twitch Username\"\n"
         "    /set irc.server.twitch.password \"oauth:My Oauth Key\"\n"

I could open a MR upstream to merged diffs. But why those split command diverged?

stacyharper commented 5 months ago

https://github.com/mumixam/weechat-twitch/pull/20

mumixam commented 5 months ago

Sorry for the delay. I see now i committed some code to my scripts repo 4 years ago but it never made it to the weechat script repo. I will submit script update PR in the next day or so hopefully i'm trying to get some clarification from @stacyharper about the changed with split()

mumixam commented 5 months ago

please close this PR. I have created my own

556

stacyharper commented 5 months ago

quoting me as co-author of the commit woud have been gentleman

mumixam commented 5 months ago

Ok seeing as Flash hasn't accept the PR yet i went ahead and added your name to it. https://github.com/weechat/scripts/commit/8dbcd4ca0f5cd541caa36c6d0bae81226eeed041