Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

stacyharper
Copy link
Contributor

@stacyharper stacyharper commented Jun 20, 2024

Script info

  • Script name: 
  • Version: 
  • Requirements: 
  • Min WeeChat version: 
  • Script tags: 

Description

Checklist (new script)

  • Single commit, single file added
  • Commit message: New script name.py: short description…
  • No similar script already exists
  • Name: max 32 chars, only lower case letters, digits and underscores
  • Unique name, does not already exist in repository
  • No shebang on the first line
  • Comment in script with name/pseudo, e-mail and license
  • Only English in code/comments
  • Pure WeeChat API used, no extra API
  • Function hook_process is used for any blocking call
  • For Python script: works with Python 3 (Python 2 support is optional)
  • Score 100 / 100 displayed by weechat-script-lint

Checklist (script update)

  • Author has been contacted
  • Single commit, single file added
  • Commit message format: script_name.py X.Y: …
  • Script version and Changelog have been updated
  • For Python script: works with Python 3 (Python 2 support is optional)
  • Score 100 / 100 displayed by weechat-script-lint

Checklist (script deletion)

  • Author has been contacted
  • Single commit, single file deleted
  • Commit message format: Remove script name.py with reasons in description

@flashcode
Copy link
Member

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.

@flashcode flashcode self-assigned this Jun 20, 2024
@flashcode flashcode added feature New feature request waiting info Waiting for info from author of issue labels Jun 20, 2024
@stacyharper
Copy link
Contributor Author

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 added a commit to stacyharper/weechat-twitch that referenced this pull request Jun 21, 2024
While backporting the eval expression to weechat-scripts:

weechat/scripts#555

I did notice that both version have diverged slightly.

This MR merge back it upstream here.
@stacyharper
Copy link
Contributor Author

@mumixam
Copy link
Contributor

mumixam commented Jun 27, 2024

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
Copy link
Contributor

mumixam commented Jun 29, 2024

please close this PR.
I have created my own
#556

@stacyharper
Copy link
Contributor Author

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

@mumixam
Copy link
Contributor

mumixam commented Jun 30, 2024

Ok seeing as Flash hasn't accept the PR yet i went ahead and added your name to it.
8dbcd4c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request waiting info Waiting for info from author of issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants