mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-22 09:18:13 +00:00
21 lines
581 B
Python
21 lines
581 B
Python
import logging
|
|
import redis
|
|
import json
|
|
from dss import settings
|
|
|
|
logger = logging.getLogger('dss')
|
|
|
|
|
|
def post_activity(channel, message, session=''):
|
|
try:
|
|
r = redis.StrictRedis(host=settings.REDIS_HOST, port=6379, db=0)
|
|
payload = json.dumps({'session': session, 'message': message})
|
|
response = r.publish(channel, payload)
|
|
logger.debug("Message sent: {0}".format(payload))
|
|
except Exception as ex:
|
|
logger.error(ex)
|
|
|
|
if __name__ == '__main__':
|
|
post_activity('site:broadcast', 'bargle', '3a596ca6c97065a67aca3dc4a3ba230d688cf413')
|
|
|