42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import os
|
|
import slack
|
|
import import_db
|
|
from random import randrange as rr
|
|
'''
|
|
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
|
|
|
|
|
|
response = client.chat_postMessage(
|
|
channel='#general',
|
|
text='Hello, world!'
|
|
)
|
|
assert response['ok']
|
|
assert response['message']['text'] == 'Hello, world!'
|
|
'''
|
|
print('I am running.')
|
|
|
|
words = import_db.import_cf_words()
|
|
|
|
@slack.RTMClient.run_on(event='message')
|
|
def say_hello(**payload):
|
|
print(payload['data'])
|
|
data = payload['data']
|
|
web_client = payload['web_client']
|
|
rtm_client = payload['rtm_client']
|
|
try:
|
|
if 'cf' in data['text'].lower():
|
|
channel_id = data['channel']
|
|
thread_ts = data['ts']
|
|
user = data['user']
|
|
|
|
web_client.chat_postMessage(
|
|
channel=channel_id,
|
|
text='CF, also known as: {0} {1}'.format((words['c'][rr(len(words['c']))]).capitalize(), (words['f'][rr(len(words['f']))]).capitalize()),
|
|
)
|
|
except:
|
|
print('lmao wtf')
|
|
|
|
slack_token = os.environ["SLACK_API_TOKEN"]
|
|
rtm_client = slack.RTMClient(token=slack_token)
|
|
rtm_client.start()
|
|
|