mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-26 11:17:59 +00:00
18 lines
460 B
Python
18 lines
460 B
Python
import json
|
|
import datetime
|
|
import redis
|
|
from dss import settings
|
|
|
|
|
|
def post_chat(session, image, user, message):
|
|
r = redis.StrictRedis(host=settings.REDIS_HOST, port=6379, db=0)
|
|
payload = json.dumps({
|
|
'session': session,
|
|
'message': message,
|
|
'user': user,
|
|
'image': image,
|
|
'date': datetime.datetime.now().isoformat()
|
|
})
|
|
response = r.publish('chat', payload)
|
|
print "Message sent: {0}".format(response)
|