-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpgbot2.py
43 lines (31 loc) · 879 Bytes
/
rpgbot2.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
import asyncio
import concurrent
import os
import threading
import slack
from flask import Flask
from flask_restful import Api
from api.test_resource import Test
from common import slack_token
import util.slack_rtm_on_message
import game_loop as game_loop
def run_api():
app = Flask(__name__)
api = Api(app)
api.add_resource(Test, "/test/<string:name>")
app.run(host='0.0.0.0', port=5000)
def run_game_loop():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
game_loop.game_loop()
def main():
asyncio.get_child_watcher()
api_thread = threading.Thread(target=run_api)
api_thread.daemon = True
api_thread.start()
game_thread = threading.Thread(target=run_game_loop)
game_thread.daemon = True
game_thread.start()
rtm_client = slack.RTMClient(token=slack_token)
rtm_client.start()
main()