aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-10-24 23:15:55 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:52 +0100
commite635272b39436b100badec940d83f2f0d4ad2e38 (patch)
tree9cf1f228694505ef82c7d406677209de9d8e382b
parent9f938758633224f9ddacdbb730bf877a631fea03 (diff)
downloadwee-slack-e635272b39436b100badec940d83f2f0d4ad2e38.tar.gz
Move from slack/main.py to slack.py
Having it in slack/main.py doesn't work with combining to one file.
-rw-r--r--slack.py45
-rw-r--r--slack/main.py46
2 files changed, 43 insertions, 48 deletions
diff --git a/slack.py b/slack.py
index 7505f66..875b44c 100644
--- a/slack.py
+++ b/slack.py
@@ -1,11 +1,52 @@
+from __future__ import annotations
+
import os
import sys
+import weechat
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from slack import globals as G # pylint: disable=wrong-import-position
-from slack.main import main # pylint: disable=wrong-import-position
+from slack.config import SlackConfig, SlackWorkspace
+from slack.task import create_task # pylint: disable=wrong-import-position
+from slack.util import get_callback_name # pylint: disable=wrong-import-position
G.weechat_callbacks = globals()
+
+def shutdown_cb():
+ weechat.config_write(G.config.weechat_config.pointer)
+ return weechat.WEECHAT_RC_OK
+
+
+async def init():
+ print(G.workspaces)
+ if "wee-slack-test" not in G.workspaces:
+ G.workspaces["wee-slack-test"] = SlackWorkspace("wee-slack-test")
+ G.workspaces[
+ "wee-slack-test"
+ ].config.api_token.value = weechat.config_get_plugin("api_token")
+ G.workspaces[
+ "wee-slack-test"
+ ].config.api_cookies.value = weechat.config_get_plugin("api_cookie")
+ workspace = G.workspaces["wee-slack-test"]
+ print(workspace)
+ print(workspace.config.slack_timeout.value)
+ print(G.config.color.reaction_suffix.value)
+
+
if __name__ == "__main__":
- main()
+ if weechat.register(
+ G.SCRIPT_NAME,
+ G.SCRIPT_AUTHOR,
+ G.SCRIPT_VERSION,
+ G.SCRIPT_LICENSE,
+ G.SCRIPT_DESC,
+ get_callback_name(shutdown_cb),
+ "",
+ ):
+ G.weechat_version = int(weechat.info_get("version_number", "") or 0)
+ G.workspaces = {}
+ G.config = SlackConfig()
+ G.config.config_read()
+ create_task(init(), final=True)
diff --git a/slack/main.py b/slack/main.py
deleted file mode 100644
index 3a4c652..0000000
--- a/slack/main.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from __future__ import annotations
-
-import weechat
-
-from . import globals as G
-from .config import SlackConfig, SlackWorkspace
-from .task import create_task
-from .util import get_callback_name
-
-
-def shutdown_cb():
- weechat.config_write(G.config.weechat_config.pointer)
- return weechat.WEECHAT_RC_OK
-
-
-async def init():
- print(G.workspaces)
- if "wee-slack-test" not in G.workspaces:
- G.workspaces["wee-slack-test"] = SlackWorkspace("wee-slack-test")
- G.workspaces[
- "wee-slack-test"
- ].config.api_token.value = weechat.config_get_plugin("api_token")
- G.workspaces[
- "wee-slack-test"
- ].config.api_cookies.value = weechat.config_get_plugin("api_cookie")
- workspace = G.workspaces["wee-slack-test"]
- print(workspace)
- print(workspace.config.slack_timeout.value)
- print(G.config.color.reaction_suffix.value)
-
-
-def main():
- if weechat.register(
- G.SCRIPT_NAME,
- G.SCRIPT_AUTHOR,
- G.SCRIPT_VERSION,
- G.SCRIPT_LICENSE,
- G.SCRIPT_DESC,
- get_callback_name(shutdown_cb),
- "",
- ):
- G.weechat_version = int(weechat.info_get("version_number", "") or 0)
- G.workspaces = {}
- G.config = SlackConfig()
- G.config.config_read()
- create_task(init(), final=True)