aboutsummaryrefslogtreecommitdiffstats
path: root/slack/proxy.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-15 00:14:48 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitecda1269f11efd861baa2b5cb3816e89af719aed (patch)
tree93a3b721605a7b093be26c6057edd70a9afe622f /slack/proxy.py
parent17d928f8ce765229690afbc78a6a31cdf24da409 (diff)
downloadwee-slack-ecda1269f11efd861baa2b5cb3816e89af719aed.tar.gz
Connect to websocket
Diffstat (limited to 'slack/proxy.py')
-rw-r--r--slack/proxy.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/slack/proxy.py b/slack/proxy.py
new file mode 100644
index 0000000..ba8e81d
--- /dev/null
+++ b/slack/proxy.py
@@ -0,0 +1,65 @@
+from __future__ import annotations
+
+import weechat
+
+
+class Proxy:
+ @property
+ def name(self):
+ return weechat.config_string(weechat.config_get("weechat.network.proxy_curl"))
+
+ @property
+ def enabled(self):
+ return bool(self.type)
+
+ @property
+ def _proxy_option_prefix(self):
+ return f"weechat.proxy.{self.name}"
+
+ @property
+ def type(self):
+ return weechat.config_string(
+ weechat.config_get(f"{self._proxy_option_prefix}.type")
+ )
+
+ @property
+ def address(self):
+ return weechat.config_string(
+ weechat.config_get(f"{self._proxy_option_prefix}.address")
+ )
+
+ @property
+ def port(self):
+ return weechat.config_integer(
+ weechat.config_get(f"{self._proxy_option_prefix}.port")
+ )
+
+ @property
+ def ipv6(self):
+ return weechat.config_boolean(
+ weechat.config_get(f"{self._proxy_option_prefix}.ipv6")
+ )
+
+ @property
+ def username(self):
+ return weechat.config_string(
+ weechat.config_get(f"{self._proxy_option_prefix}.username")
+ )
+
+ @property
+ def password(self):
+ return weechat.config_string(
+ weechat.config_get(f"{self._proxy_option_prefix}.password")
+ )
+
+ @property
+ def curl_option(self):
+ if not self.enabled:
+ return ""
+
+ user = (
+ f"{self.username}:{self.password}@"
+ if self.username and self.password
+ else ""
+ )
+ return f"-x{self.type}://{user}{self.address}:{self.port}"