-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (25 loc) · 788 Bytes
/
main.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
import time
import slack as Bot
from slacker import Slacker
from slackclient import SlackClient
import os
# token = os.environ.get('CHATBOTKEY')
token = os.environ.get('CHATBOTKEY')
slack = Slacker(token)
slack_client = SlackClient(token)
flag = False
if __name__ == "__main__":
READ_WEBSOKET_DELAY = 1
if slack_client.rtm_connect():
print("server is running")
while True:
command, channel = Bot.parse_slack_output(slack_client.rtm_read())
# if not flag:
# command = "contest"
# channel = "C319P19LJ"
# flag = True
if command and channel:
Bot.handle_command(command, channel)
time.sleep(READ_WEBSOKET_DELAY)
else:
print("error")