aboutsummaryrefslogtreecommitdiffstats
path: root/slack/init.py
blob: ff95f57fb826d315e6fd4802a8cdba073b0583cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import weechat

from slack.commands import register_commands
from slack.config import SlackConfig, SlackWorkspace
from slack.shared import shared
from slack.task import create_task
from slack.util import get_callback_name

SCRIPT_AUTHOR = "Trygve Aaberge <trygveaa@gmail.com>"
SCRIPT_LICENSE = "MIT"
SCRIPT_DESC = "Extends weechat for typing notification/search/etc on slack.com"
REPO_URL = "https://github.com/wee-slack/wee-slack"


def shutdown_cb():
    weechat.config_write(shared.config.weechat_config.pointer)
    return weechat.WEECHAT_RC_OK


async def init():
    pass
    # print(shared.workspaces)
    # if "wee-slack-test" not in shared.workspaces:
    #     shared.workspaces["wee-slack-test"] = SlackWorkspace("wee-slack-test")
    #     shared.workspaces[
    #         "wee-slack-test"
    #     ].config.api_token.value = weechat.config_get_plugin("api_token")
    #     shared.workspaces[
    #         "wee-slack-test"
    #     ].config.api_cookies.value = weechat.config_get_plugin("api_cookie")
    # workspace = shared.workspaces["wee-slack-test"]
    # print(workspace)
    # print(workspace.config.slack_timeout.value)
    # print(shared.config.color.reaction_suffix.value)


def main():
    if weechat.register(
        shared.SCRIPT_NAME,
        SCRIPT_AUTHOR,
        shared.SCRIPT_VERSION,
        SCRIPT_LICENSE,
        SCRIPT_DESC,
        get_callback_name(shutdown_cb),
        "",
    ):
        shared.weechat_version = int(weechat.info_get("version_number", "") or 0)
        shared.workspaces = {}
        shared.config = SlackConfig()
        shared.config.config_read()
        register_commands()
        create_task(init(), final=True)