aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-02-09 15:39:47 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-02-23 18:47:05 +0100
commit324890c3d0155a700fb247f5ee8f3b0778d83fe5 (patch)
treeb0654827e35e7d25186073c0a339b24db2e1fdab /wee_slack.py
parentba75367a097167b0f6c2f255a096ec50ae3316cf (diff)
downloadwee-slack-324890c3d0155a700fb247f5ee8f3b0778d83fe5.tar.gz
Simplify passing ws metadata
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py39
1 files changed, 10 insertions, 29 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 3d20c28..bf144ff 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -503,10 +503,7 @@ class EventRouter(object):
return w.WEECHAT_RC_OK
message_json = json.loads(data.decode('utf-8'))
- metadata = WeeSlackMetadata({
- "team": team_hash,
- }).jsonify()
- message_json["wee_slack_metadata"] = metadata
+ message_json["wee_slack_metadata_team"] = team
if self.recording:
self.record_event(message_json, 'type', 'websocket')
self.receive(message_json)
@@ -638,20 +635,16 @@ class EventRouter(object):
function_name = "unknown"
# Here we are passing the actual objects. No more lookups.
- meta = j.get("wee_slack_metadata")
- if meta:
+ team = j.get("wee_slack_metadata_team")
+ if team:
try:
- if isinstance(meta, basestring):
- dbg("string of metadata")
- team = meta.get("team")
- if team:
- kwargs["team"] = self.teams[team]
- if "user" in j:
- kwargs["user"] = self.teams[team].users[j["user"]]
- if "channel" in j:
- kwargs["channel"] = self.teams[team].channels[j["channel"]]
- if "subteam" in j:
- kwargs["subteam"] = self.teams[team].subteams[j["subteam"]]
+ kwargs["team"] = team
+ if "user" in j:
+ kwargs["user"] = team.users[j["user"]]
+ if "channel" in j:
+ kwargs["channel"] = team.channels[j["channel"]]
+ if "subteam" in j:
+ kwargs["subteam"] = team.subteams[j["subteam"]]
except:
dbg("metadata failure")
@@ -2524,18 +2517,6 @@ class SlackThreadMessage(SlackMessage):
self.parent_message = parent_message
-class WeeSlackMetadata(object):
- """
- A simple container that we pickle/unpickle to hold data.
- """
-
- def __init__(self, meta):
- self.meta = meta
-
- def jsonify(self):
- return self.meta
-
-
class Hdata(object):
def __init__(self, w):
self.buffer = w.hdata_get('buffer')