aboutsummaryrefslogtreecommitdiffstats
path: root/slack/main.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-10-24 21:08:02 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:52 +0100
commite3bc88120e071eac8fabb5b02d7b509488d563e2 (patch)
treef4f7195d629e4beb2e146624575d5f9302e0ab2d /slack/main.py
parente6796bbf07a5c8ecdc3411f583814be28f163807 (diff)
downloadwee-slack-e3bc88120e071eac8fabb5b02d7b509488d563e2.tar.gz
Split into multiple files
Diffstat (limited to 'slack/main.py')
-rw-r--r--slack/main.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/slack/main.py b/slack/main.py
new file mode 100644
index 0000000..38cd167
--- /dev/null
+++ b/slack/main.py
@@ -0,0 +1,49 @@
+from __future__ import annotations
+
+import os
+import sys
+
+import weechat
+
+sys.path.append(os.path.dirname(os.path.realpath(__file__)))
+import globals # pylint: disable=wrong-import-position
+from config import SlackConfig, SlackWorkspace # pylint: disable=wrong-import-position
+from task import create_task # pylint: disable=wrong-import-position
+
+
+def shutdown_cb():
+ weechat.config_write(globals.config.weechat_config.pointer)
+ return weechat.WEECHAT_RC_OK
+
+
+async def init():
+ print(globals.workspaces)
+ if "wee-slack-test" not in globals.workspaces:
+ globals.workspaces["wee-slack-test"] = SlackWorkspace("wee-slack-test")
+ globals.workspaces[
+ "wee-slack-test"
+ ].config.api_token.value = weechat.config_get_plugin("api_token")
+ globals.workspaces[
+ "wee-slack-test"
+ ].config.api_cookies.value = weechat.config_get_plugin("api_cookie")
+ workspace = globals.workspaces["wee-slack-test"]
+ print(workspace)
+ print(workspace.config.slack_timeout.value)
+ print(globals.config.color.reaction_suffix.value)
+
+
+if __name__ == "__main__":
+ if weechat.register(
+ globals.SCRIPT_NAME,
+ globals.SCRIPT_AUTHOR,
+ globals.SCRIPT_VERSION,
+ globals.SCRIPT_LICENSE,
+ globals.SCRIPT_DESC,
+ shutdown_cb.__name__,
+ "",
+ ):
+ globals.weechat_version = int(weechat.info_get("version_number", "") or 0)
+ globals.workspaces = {}
+ globals.config = SlackConfig()
+ globals.config.config_read()
+ create_task(init(), final=True)