diff options
author | Tollef Fog Heen <tfheen@err.no> | 2018-03-09 20:58:47 +0100 |
---|---|---|
committer | Tollef Fog Heen <tfheen@err.no> | 2018-03-11 07:56:27 +0100 |
commit | 42604089ca82f87598857df1418ccc5cc52088aa (patch) | |
tree | 19e9554fd6e92693366c680503f5015d24ab3ea0 | |
parent | d5af7d8362580eb9ae4564ef52694087d427bbab (diff) | |
download | wee-slack-42604089ca82f87598857df1418ccc5cc52088aa.tar.gz |
Re-add support for weechat.look.nick_{prefix,suffix}
Fixes: #428
-rw-r--r-- | _pytest/conftest.py | 4 | ||||
-rw-r--r-- | wee_slack.py | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py index ca267fd..74ed537 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -76,6 +76,10 @@ class FakeWeechat(): return "" def config_get_plugin(self, key): return "" + def config_get(self, key): + return "" + def config_string(self, key): + return "" def color(self, name): return "" def __getattr__(self, name): diff --git a/wee_slack.py b/wee_slack.py index efa4df9..b6d0449 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1353,8 +1353,9 @@ class SlackChannel(object): s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["leave"], {"channel": self.identifier}, team_hash=self.team.team_hash, channel_identifier=self.identifier) self.eventrouter.receive(s) + def buffer_prnt(self, nick, text, timestamp=str(time.time()), tagset=None, tag_nick=None, **kwargs): - data = "{}\t{}".format(nick, text) + data = "{}\t{}".format(format_nick(nick), text) ts = SlackTS(timestamp) last_read = SlackTS(self.last_read) # without this, DMs won't open automatically @@ -1802,7 +1803,7 @@ class SlackThreadChannel(object): w.buffer_set(self.channel_buffer, "hotlist", "-1") def buffer_prnt(self, nick, text, timestamp, **kwargs): - data = "{}\t{}".format(nick, text) + data = "{}\t{}".format(format_nick(nick), text) ts = SlackTS(timestamp) if self.channel_buffer: # backlog messages - we will update the read marker as we print these @@ -2925,6 +2926,17 @@ def modify_print_time(buffer, new_id, time): return w.WEECHAT_RC_OK +def format_nick(nick): + nick_prefix = w.config_string(w.config_get('weechat.look.nick_prefix')) + nick_prefix_color_name = w.config_string(w.config_get('weechat.color.chat_nick_prefix')) + nick_prefix_color = w.color(nick_prefix_color_name) + + nick_suffix = w.config_string(w.config_get('weechat.look.nick_suffix')) + nick_suffix_color_name = w.config_string(w.config_get('weechat.color.chat_nick_prefix')) + nick_suffix_color = w.color(nick_suffix_color_name) + return nick_prefix_color + nick_prefix + w.color("reset") + nick + nick_suffix_color + nick_suffix + w.color("reset") + + def tag(tagset, user=None): if user: user.replace(" ", "_") |