diff --git a/bin/darkirc/script/bots/telegram-mirror-bot.py b/bin/darkirc/script/bots/telegram-mirror-bot.py index d4ead6f3b..e57776076 100644 --- a/bin/darkirc/script/bots/telegram-mirror-bot.py +++ b/bin/darkirc/script/bots/telegram-mirror-bot.py @@ -15,7 +15,7 @@ MAX_NICK_LENGTH = 10 MAX_MESSAGE_LENGTH = MessageLimit.MAX_TEXT_LENGTH - (MAX_CHANNEL_LENGTH + MAX_NICK_LENGTH + 16) SERVER = "127.0.0.1" -PORT = 22025 +PORT = 6645 CHANNELS = ["#dev","#memes","#philosophy","#markets","#math","#random",] BOTNICK = "tgbridge" @@ -60,8 +60,6 @@ ircc.connect(SERVER, PORT, CHANNELS, BOTNICK) async def main(): while True: text = ircc.get_response() - # print("loop") - print("text: " + text) if not len(text) > 0: print("Error: disconnected from server") exit(-1) @@ -94,7 +92,7 @@ async def main(): message = nick + message[7:] nick = "*" - # append_log(channel, nick, message) + append_log(channel, nick, message) # Pad and left/right justify channel and nickname channel = channel[:MAX_CHANNEL_LENGTH].ljust(MAX_CHANNEL_LENGTH) @@ -104,22 +102,21 @@ async def main(): while len(message) > 0: string_to_telegram = f"{channel} {nick} | {message[:MAX_MESSAGE_LENGTH]}" - print("tele: " + string_to_telegram) - # # Keep retrying until the fucker is sent - # while True: - # try: - # async with Bot(TOKEN) as bot: - # await bot.send_message("@darkfi_darkirc", string_to_telegram, - # parse_mode="HTML", - # disable_notification=True, - # disable_web_page_preview=True) - # break - # #except telegram.error.BadRequest: - # # pass - # except: - # print(channel, string_to_telegram) - # print(traceback.format_exc()) - # await asyncio.sleep(3) + # Keep retrying until the fucker is sent + while True: + try: + async with Bot(TOKEN) as bot: + await bot.send_message("@darkfi_darkirc", string_to_telegram, + parse_mode="HTML", + disable_notification=True, + disable_web_page_preview=True) + break + #except telegram.error.BadRequest: + # pass + except: + print(channel, string_to_telegram) + print(traceback.format_exc()) + await asyncio.sleep(3) message = message[MAX_MESSAGE_LENGTH:]