aboutsummaryrefslogtreecommitdiff
path: root/chat
diff options
context:
space:
mode:
Diffstat (limited to 'chat')
-rw-r--r--chat/chat_cache.py3
-rw-r--r--chat/consumers.py8
-rw-r--r--chat/routing.py1
-rw-r--r--chat/skippy.py1
4 files changed, 10 insertions, 3 deletions
diff --git a/chat/chat_cache.py b/chat/chat_cache.py
index 08cbf178..43354ef7 100644
--- a/chat/chat_cache.py
+++ b/chat/chat_cache.py
@@ -1,6 +1,7 @@
-import redis
import json
+import redis
+
r = redis.Redis(host='localhost', port=6379, db=0)
def handle_connect():
diff --git a/chat/consumers.py b/chat/consumers.py
index 0b3017c4..da81449c 100644
--- a/chat/consumers.py
+++ b/chat/consumers.py
@@ -1,9 +1,13 @@
import json
-from channels.generic.websocket import WebsocketConsumer
+
from asgiref.sync import async_to_sync
-from .chat_cache import handle_connect, handle_disconnect, handle_alone_user, discard_user_messages
+from channels.generic.websocket import WebsocketConsumer
+
+from .chat_cache import (discard_user_messages, handle_alone_user,
+ handle_connect, handle_disconnect)
from .skippy import invokeMFSkippy
+
class ChatConsumer(WebsocketConsumer):
def connect(self):
self.room_group_name = "chat"
diff --git a/chat/routing.py b/chat/routing.py
index 69101be1..fe6b4681 100644
--- a/chat/routing.py
+++ b/chat/routing.py
@@ -1,4 +1,5 @@
from django.urls import re_path
+
from . import consumers
websocket_urlpatterns = [
diff --git a/chat/skippy.py b/chat/skippy.py
index bf6ab6ac..6fa3aaa1 100644
--- a/chat/skippy.py
+++ b/chat/skippy.py
@@ -1,5 +1,6 @@
from .chat_cache import get_user_messages, save_user_messages
+
def invokeMFSkippy(message, identifier):
save_user_messages(user_identifier=identifier, message={'content': message, 'role': 'user'})
user_messages = get_user_messages(user_identifier=identifier)