aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-01-30 17:26:52 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2022-09-17 18:56:26 +0200
commit5a957b05a3b5f5707ad30b73d4440f2dc974d9bf (patch)
tree50495d0e1c8780b6c88d2feeef0df83e8ed68d25 /wee_slack.py
parent2185a5838e551643de31e10e4d57c617194e74d0 (diff)
downloadwee-slack-5a957b05a3b5f5707ad30b73d4440f2dc974d9bf.tar.gz
Support specifying an auth cookie in slack_api_token
This is necessary for xoxc tokens. The cookie is specified after the token with a colon separating them, i.e. "token1,token2:cookiefor2,token3". This makes slack_api_token even more inconvenient, but it will have to do until we rewrite the config to have a section for each team, like the irc config has. Fixes #844
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 12b310e..e0b32e1 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1441,6 +1441,10 @@ class SlackRequest(object):
self.retries = retries
self.token = token if token else team.token
self.cookies = cookies or {}
+ if ":" in self.token:
+ token, cookie = self.token.split(":", 1)
+ self.token = token
+ self.cookies["d"] = cookie
self.callback = callback
self.domain = "api.slack.com"
self.reset()
@@ -7029,5 +7033,13 @@ if __name__ == "__main__":
),
)
for t in tokens:
- initiate_connection(t)
+ if t.startswith("xoxc-") and ":" not in t:
+ w.prnt(
+ "",
+ "{}When using an xoxc token, you need to also provide the d cookie in the format token:cookie".format(
+ w.prefix("error")
+ ),
+ )
+ else:
+ initiate_connection(t)
EVENTROUTER.handle_next()