Verified Commit e6cb633a authored by Mroik's avatar Mroik
Browse files

More logging

parent fa3dc529
RETURN_CODE = (
"",
"Connection refused – incorrect protocol version",
"Connection refused – invalid client identifier",
"Connection refused – server unavailable",
"Connection refused – bad username or password",
"Connection refused – not authorised"
)
import logging
from tgbot import updater, where_am_i
from mt.const import RETURN_CODE
LOGGER = logging.getLogger(__name__)
def on_connect(client, userdata, flags, rc):
print("Connected with rc:", rc)
client.subscribe("sede/status") # Maybe should make it into a constant set'd from config file
if rc > 0:
LOGGER.error(RETURN_CODE[rc])
return
res, mid = client.subscribe("sede/status") # Maybe should make it into a constant set'd from config file
LOGGER.info(res, mid)
def on_message(client, userdata, msg):
print("Received:", msg.topic, "\tWith:", msg.payload.decode("utf-8"))
LOGGER.debug("Received:", msg.topic, "\tWith:", msg.payload.decode("utf-8"))
if msg.topic != "sede/status":
return
if msg.payload.decode("utf-8") == "1":
......
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