aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2018-05-21 11:06:13 +0200
committerTollef Fog Heen <tfheen@err.no>2018-05-21 11:06:13 +0200
commitfaf02adfda81d694746efeedbbe2e5c64b37c79a (patch)
tree41ccc5b23d7486b225f37a25c14cadb0bc7b5627 /wee_slack.py
parente69e1ace2fd35c4b3cdec8f7bb41e3e2eefe0eee (diff)
downloadwee-slack-faf02adfda81d694746efeedbbe2e5c64b37c79a.tar.gz
Fix a bunch of PEP8 errors
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 27ec621..22d9cc6 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1170,7 +1170,8 @@ class SlackTeam(object):
self.send_to_websocket({
"type": "presence_sub",
"ids": users,
- }, expect_reply=False)
+ }, expect_reply=False)
+
class SlackChannel(object):
"""
@@ -1359,7 +1360,6 @@ 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(format_nick(nick), text)
ts = SlackTS(timestamp)
@@ -1560,10 +1560,10 @@ class SlackChannel(object):
# if they do, use the existing pointer
here = w.nicklist_search_group(self.channel_buffer, '', NICK_GROUP_HERE)
if not here:
- here = w.nicklist_add_group(self.channel_buffer, '', NICK_GROUP_HERE, "weechat.color.nicklist_group", 1)
+ here = w.nicklist_add_group(self.channel_buffer, '', NICK_GROUP_HERE, "weechat.color.nicklist_group", 1)
afk = w.nicklist_search_group(self.channel_buffer, '', NICK_GROUP_AWAY)
if not afk:
- afk = w.nicklist_add_group(self.channel_buffer, '', NICK_GROUP_AWAY, "weechat.color.nicklist_group", 1)
+ afk = w.nicklist_add_group(self.channel_buffer, '', NICK_GROUP_AWAY, "weechat.color.nicklist_group", 1)
if user and len(self.members) < 1000:
user = self.team.users[user]
@@ -2143,7 +2143,7 @@ def handle_rtmstart(login_data, eventrouter):
if not login_data["ok"]:
w.prnt("", "ERROR: Failed connecting to Slack with token starting with {}: {}"
- .format(metadata.token[:15], login_data["error"]))
+ .format(metadata.token[:15], login_data["error"]))
return
# Let's reuse a team if we have it already.
@@ -2216,6 +2216,7 @@ def handle_channelsinfo(channel_json, eventrouter, **kwargs):
channel.set_unread_count_display(channel_json['channel']['unread_count_display'])
channel.set_members(channel_json['channel']['members'])
+
def handle_groupsinfo(group_json, eventrouter, **kwargs):
request_metadata = pickle.loads(group_json["wee_slack_request_metadata"])
team = eventrouter.teams[request_metadata.team_hash]
@@ -2224,6 +2225,7 @@ def handle_groupsinfo(group_json, eventrouter, **kwargs):
group_id = group_json['group']['id']
group.set_unread_count_display(unread_count_display)
+
def handle_conversationsopen(conversation_json, eventrouter, object_name='channel', **kwargs):
request_metadata = pickle.loads(conversation_json["wee_slack_request_metadata"])
# Set unread count if the channel isn't new (channel_identifier exists)
@@ -2270,11 +2272,12 @@ def handle_history(message_json, eventrouter, **kwargs):
for message in reversed(message_json["messages"]):
process_message(message, eventrouter, **kwargs)
-###### New/converted process_ and subprocess_ methods
+###### New/converted process_ and subprocess_ methods
def process_hello(message_json, eventrouter, **kwargs):
kwargs['team'].subscribe_users_presence()
+
def process_reconnect_url(message_json, eventrouter, **kwargs):
kwargs['team'].set_reconnect_url(message_json['url'])
@@ -2621,8 +2624,8 @@ def process_emoji_changed(message_json, eventrouter, **kwargs):
team = kwargs['team']
team.load_emoji_completions()
-###### New module/global methods
+###### New module/global methods
def render_formatting(text):
text = re.sub(r'(^| )\*([^*]+)\*([^a-zA-Z0-9_]|$)',
r'\1{}\2{}\3'.format(w.color(config.render_bold_as),
@@ -3062,6 +3065,7 @@ def topic_command_cb(data, current_buffer, command):
EVENTROUTER.receive(s)
return w.WEECHAT_RC_OK_EAT
+
@slack_buffer_or_ignore
@utf8_decode
def whois_command_cb(data, current_buffer, command):
@@ -3091,6 +3095,7 @@ def whois_command_cb(data, current_buffer, command):
team.buffer_prnt("[{}]: No such user".format(user))
return w.WEECHAT_RC_OK_EAT
+
@slack_buffer_or_ignore
@utf8_decode
def me_command_cb(data, current_buffer, args):
@@ -3130,7 +3135,7 @@ def command_register(data, current_buffer, args):
d = json.loads(ret)
if not d["ok"]:
w.prnt("",
- "ERROR: Couldn't get Slack OAuth token: {}".format(d['error']))
+ "ERROR: Couldn't get Slack OAuth token: {}".format(d['error']))
return
if config.is_default('slack_api_token'):
@@ -3445,7 +3450,7 @@ def command_status(data, current_buffer, args):
emoji = split_args[1] if len(split_args) > 1 else ""
text = split_args[2] if len(split_args) > 2 else ""
- profile = {"status_text":text,"status_emoji":emoji}
+ profile = {"status_text": text, "status_emoji": emoji}
s = SlackRequest(team.token, "users.profile.set", {"profile": profile}, team_hash=team.team_hash)
EVENTROUTER.receive(s)
@@ -3621,11 +3626,10 @@ def dbg(message, level=0, main_buffer=False, fout=False):
# w.prnt(slack_debug, "---------")
w.prnt(slack_debug, message)
-###### Config code
-
-Setting = collections.namedtuple('Setting', ['default', 'desc'])
+###### Config code
class PluginConfig(object):
+ Setting = collections.namedtuple('Setting', ['default', 'desc'])
# Default settings.
# These are, initially, each a (default, desc) tuple; the former is the
# default value of the setting, in the (string) format that weechat
@@ -3854,13 +3858,14 @@ def trace_calls(frame, event, arg):
f.flush()
return
+
def initiate_connection(token, retries=3):
return SlackRequest(token,
- 'rtm.start',
- {"batch_presence_aware": 1 },
- retries=retries)
+ 'rtm.start',
+ {"batch_presence_aware": 1},
+ retries=retries)
+
-# Main
if __name__ == "__main__":
w = WeechatWrapper(weechat)