def add_message_reaction(self, slackAPIToken, channel, timestamp, reaction, remove):
try:
if reaction == None:
return
reaction = reaction.strip()
if len(reaction) == 0:
return
slackAPIConnection = Slacker(slackAPIToken)
self._logger.debug("Sending Slack RTM reaction - Channel: " + channel + ", Timestamp: " + timestamp + ", Reaction: " + reaction + ", Remove: " + str(remove))
if remove:
reaction_rsp = slackAPIConnection.reactions.remove(channel=channel, timestamp=timestamp, name=reaction)
else:
reaction_rsp = slackAPIConnection.reactions.add(channel=channel, timestamp=timestamp, name=reaction)
if reaction_rsp.successful == None or reaction_rsp.successful == False:
self._logger.debug("Slack RTM send reaction failed - Channel: " + channel + ", Timestamp: " + timestamp + ", Reaction: " + reaction + ", Remove: " + str(remove) + json.dumps(reaction_rsp.body))
else:
self._logger.debug("Successfully sent Slack RTM reaction - Channel: " + channel + ", Timestamp: " + timestamp + ", Reaction: " + reaction + ", Remove: " + str(remove))
except Exception as e:
self._logger.exception("Error sending Slack RTM reaction - Channel: " + channel + ", Timestamp: " + timestamp + ", Reaction: " + reaction + ", Remove: " + str(remove) + ", Error: " + str(e.message))
评论列表
文章目录