Commit ce1cb4f5 authored by JackV's avatar JackV

Use environment variables, cleanup

parent 4b53ce63
import websockets
import asyncio import asyncio
from telegram import Bot
import json import json
import os
import websockets
from telegram import Bot
WS_URL = "wss://bits.poul.org/ws" WS_URL = os.environ.get('WS_URL', "wss://bits.poul.org/ws")
CHAT_ID = 123 #CHANGE ME CHAT_ID = int(os.environ.get('CHAT_ID'))
MESSAGE_ID = 123 #CHANGE ME MESSAGE_ID = int(os.environ.get('MESSAGE_ID'))
TOKEN = "KEK" TOKEN = os.environ.get('TOKEN')
bot = Bot(TOKEN) bot = Bot(TOKEN)
def bits_handler(text): def bits_handler(text):
meme = json.loads(text) msg = json.loads(text)
bot.edit_message_text("POuL HQ is now {}".format(meme["status"]["value"]), CHAT_ID, MESSAGE_ID) bot.edit_message_text("POuL HQ is now {}".format(msg["status"]["value"]), CHAT_ID, MESSAGE_ID)
return return
class WebSocketClient: class WebSocketClient:
...@@ -50,4 +51,4 @@ if __name__ == '__main__': ...@@ -50,4 +51,4 @@ if __name__ == '__main__':
asyncio.ensure_future(client.heartbeat()), asyncio.ensure_future(client.heartbeat()),
asyncio.ensure_future(client.receiveMessage(connection, bits_handler)), asyncio.ensure_future(client.receiveMessage(connection, bits_handler)),
] ]
loop.run_until_complete(asyncio.wait(tasks)) loop.run_until_complete(asyncio.wait(tasks))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment