diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2022-11-21 00:17:24 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | f5ed482e03756ae63ace7c5707259c67d770bfa9 (patch) | |
tree | fd98404e158fa6a43ee6e3038c2a122ce11ffc70 /slack/api.py | |
parent | 0a7aecb9e8398a32fc041411ae45b85bcf477cea (diff) | |
download | wee-slack-f5ed482e03756ae63ace7c5707259c67d770bfa9.tar.gz |
Add buffer input callback
Diffstat (limited to 'slack/api.py')
-rw-r--r-- | slack/api.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/slack/api.py b/slack/api.py index f0cad96..e0aa319 100644 --- a/slack/api.py +++ b/slack/api.py @@ -11,6 +11,7 @@ import weechat from slack.http import http_request from slack.shared import shared from slack.task import create_task, gather +from slack.util import get_callback_name if TYPE_CHECKING: from slack_api import ( @@ -124,6 +125,11 @@ class SlackUser: self.name = info["user"]["name"] +def buffer_input_cb(data: str, buffer: str, input_data: str) -> int: + weechat.prnt(buffer, "Text: %s" % input_data) + return weechat.WEECHAT_RC_OK + + class SlackConversation: def __init__(self, workspace: SlackWorkspace, id: str): self.workspace = workspace @@ -146,7 +152,10 @@ class SlackConversation: async def init(self): info = await self.fetch_info() self.name = info["channel"]["name"] - self.buffer_pointer = weechat.buffer_new(self.name, "", "", "", "") + self.buffer_pointer = weechat.buffer_new( + self.name, get_callback_name(buffer_input_cb), "", "", "" + ) + weechat.buffer_set(self.buffer_pointer, "localvar_set_nick", "nick") async def fetch_info(self): self.set_loading(True) |