-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslackmq.py
43 lines (39 loc) · 1.5 KB
/
slackmq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from slacker import Slacker
from time import sleep
class slackmq(object):
def __init__(self, api_token, channel, timestamp):
self.api_token = api_token
self.channel = channel
self.timestamp = timestamp
def ack(self, emoji=None, stars=None):
try:
slack = Slacker(self.api_token)
slack.pins.add(channel=self.channel,
timestamp=self.timestamp)
if stars is not None:
slack.stars.add(channel=self.channel,
timestamp=self.timestamp)
if emoji is not None:
slack.reactions.add(emoji,
channel=self.channel,
timestamp=self.timestamp)
except Exception:
return False
return True
def unack(self, emoji=None, stars=None):
try:
sleep(3)
slack = Slacker(self.api_token)
slack.pins.remove(channel=self.channel,
timestamp=self.timestamp)
if emoji is not None:
sleep(3)
slack.reactions.remove(emoji,
channel=self.channel,
timestamp=self.timestamp)
if stars is not None:
sleep(3)
slack.stars.remove(channel=self.channel,
timestamp=self.timestamp)
except Exception:
return False