Start of chat command handling
This commit is contained in:
18
chatCommands.py
Normal file
18
chatCommands.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def handle_command(kwargs):
|
||||||
|
|
||||||
|
command = kwargs['message'].split()[0]
|
||||||
|
print(command)
|
||||||
|
|
||||||
|
|
||||||
|
def custom_roll(character, message):
|
||||||
|
print('asd')
|
||||||
|
|
||||||
|
|
||||||
|
commands: Dict = {
|
||||||
|
'/roll': custom_roll
|
||||||
|
}
|
||||||
6
main.py
6
main.py
@@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
import chatCommands
|
||||||
|
|
||||||
from flask import Flask, request
|
from flask import Flask, request
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
@@ -12,6 +13,7 @@ cors = CORS(app)
|
|||||||
sio = SocketIO(app, cors_allowed_origins='*')
|
sio = SocketIO(app, cors_allowed_origins='*')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
return {'url': '/', 'body': 'test body'}
|
return {'url': '/', 'body': 'test body'}
|
||||||
@@ -36,6 +38,10 @@ def test(user):
|
|||||||
|
|
||||||
@sio.on('public message')
|
@sio.on('public message')
|
||||||
def public_message(kwargs):
|
def public_message(kwargs):
|
||||||
|
kwargs['message'].strip()
|
||||||
|
if 'message' in kwargs:
|
||||||
|
if kwargs['message'][0] == '/':
|
||||||
|
chatCommands.handle_command(kwargs)
|
||||||
print(kwargs)
|
print(kwargs)
|
||||||
sio.emit('public message', kwargs)
|
sio.emit('public message', kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user