#!/usr/bin/env python3 from telegram import Bot import sys import re import config from emoji import emojize bot = Bot(token=config.api_key) for line in sys.stdin: text = "" parse_mode = None if not re.match(".* Mod performs HTTP request with URL ", line): print(line, end="") if re.match(r".*ACTION\[Server\]: CHAT", line): text = re.sub(".*?CHAT: ", "", line) elif re.match(r".*?(\w+ (leaves|joins) game.*)", line): text = "" text += re.sub(r".*?(\w+ (leaves|joins) game\.).*", r"\1", line) text += "\nList of players: \n" text += "\n".join(re.sub(r".*?: ", "", line).split(" ")) text += "" parse_mode = "HTML" if text != "": print(text) for i in config.groups: if parse_mode: bot.send_message(chat_id=i, text=emojize(text), parse_mode=parse_mode) else: bot.send_message(chat_id=i, text=emojize(text))