Прощай, мерзкий config_python.py

This commit is contained in:
lulzette 2024-05-01 16:22:12 +03:00
parent d8a9efffbe
commit 6849a5c801

View File

@ -50,7 +50,7 @@ def stream_message_worker(data: dict):
"Длительность: " + str(stream_duration)
# Готовим кнопку
stream_button = types.InlineKeyboardButton('Открыть стрим', url='https://twitch.tv/'+streamer)
stream_button = types.InlineKeyboardButton('Открыть стрим', url='https://twitch.tv/'+config_python.streamer)
keyboard = types.InlineKeyboardMarkup()
keyboard.add(stream_button)
@ -66,7 +66,7 @@ def stream_message_worker(data: dict):
if msgid == 0:
# Отправляем новое сообщение
send_message = bot.send_photo(config_python.tgchat, InputFile('tmppic.jpg'), message, reply_markup=keyboard,
send_message = bot.send_photo(config_python.target_tg_chat, InputFile('tmppic.jpg'), message, reply_markup=keyboard,
parse_mode='MarkdownV2')
print(send_message)
msgid = send_message.message_id
@ -77,9 +77,9 @@ def stream_message_worker(data: dict):
# Готовим медиа для отправки
media = telebot.types.InputMediaPhoto(InputFile('tmppic.jpg'))
# Редактируем фотку
edit_msg_media = bot.edit_message_media(media, config_python.tgchat, msgid, reply_markup=keyboard)
edit_msg_media = bot.edit_message_media(media, config_python.target_tg_chat, msgid, reply_markup=keyboard)
# Редактируем текст
edit_msg_caption = bot.edit_message_caption(message, config_python.tgchat, msgid, reply_markup=keyboard,
edit_msg_caption = bot.edit_message_caption(message, config_python.target_tg_chat, msgid, reply_markup=keyboard,
parse_mode='MarkdownV2')
except telebot.apihelper.ApiTelegramException as e:
log.error(e)
@ -97,11 +97,11 @@ def no_stream_msg_worker():
# Если пустой - удаляем
os.remove('msgid')
else:
if config_python.delete_msg:
if config_python.cleanup_msg:
# Если не пустой, то удаляем сообщение по айдишнику
try:
# Удаляем сообщение
edit_msg = bot.delete_message(config_python.tgchat, int(msgid))
edit_msg = bot.delete_message(config_python.target_tg_chat, int(msgid))
except telebot.apihelper.ApiTelegramException as e:
log.error(e)
# В конце удаляем айди сообщения
@ -162,8 +162,8 @@ if __name__ == '__main__':
log.info("Запущен")
config_python = load_config()
twitch_client = Twitch(config_python.app_id, config_python.app_secret)
bot = telebot.TeleBot(config_python.tgtoken)
bot = telebot.TeleBot(config_python.tg_token)
while True:
check_alive()
time.sleep(config_python.period)
time.sleep(config_python.check_period)