Aberrant/events.py

19 lines
411 B
Python
Raw Normal View History

2019-09-01 16:48:45 -04:00
#!/usr/bin/env python3
"""
WebSocket events.
"""
import types
import rtorrent
async def active_torrents(ws, data):
"""Returns active torrent information."""
data = [vars(t) for t in rtorrent.get_active()]
res = {'event': 'active_torrents', 'data': data}
await ws.send_json(res)
events = {}
for obj in dir():
if type(locals()[obj]) == types.FunctionType:
events[locals()[obj].__name__] = locals()[obj]