darkirc/script/bots: fix accidentally messed up telegram bot

This commit is contained in:
dasman
2025-03-06 03:23:59 +03:00
parent 1b3454dd29
commit 012f5dec23

View File

@@ -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"<code>{channel} {nick} |</code> {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:]