-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.py
28 lines (20 loc) · 863 Bytes
/
bot.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
from slackclient import SlackClient
import json
import os
ICON = ":guitar:"
class Bot(object):
def __init__(self):
self._client = SlackClient(self._token())
self._icon = ICON
self._client.rtm_connect()
def _token(self):
return os.environ['SLACKBOT_TOKEN']
def _channel(self):
return os.environ.get('CHANNEL', 'musicreactions')
def _username(self):
return os.environ.get('SLACK_USERNAME', 'Discobear')
def say(self, message):
self._client.rtm_send_message(self._channel, message)
def sayEx(self, text, image, footer):
d = {'thumb_url': image, 'text': text, "footer": footer, "fallback": text}
self._client.api_call("chat.postMessage", channel=self._channel(), username=self._username(), as_user="false", icon_emoji=self._icon, attachments=json.dumps([d]))