ŠLUDBA, zábrana erroru u kabelové verze

This commit is contained in:
2026-03-19 22:23:37 +01:00
parent 75325f3b3e
commit fd24acf82a
13 changed files with 75 additions and 4 deletions

30
main.py
View File

@@ -12,6 +12,7 @@ CZCHAN_LLM_KEY = os.getenv("CZCHAN_LLM_KEY")
CHANCE = 1.0
IMAGE_FOLDER = "obruzky"
MUSIC_FOLDER = "hudba"
bot = telebot.TeleBot(API_KEY)
@@ -82,8 +83,20 @@ VIDEO_EXT = (
".3gpp",
".3g2",
) # 3GP JE ŽRÍJSKÉ A SUDETKEŠNÍ, ZRÁDCI POUŽÍVAJÍ MPEG
AUDIO_EXT = (
".mp3",
".wav",
".ogg",
".flac",
".m4a",
".opus",
".3gp",
".3gpp",
".3g2",
)
files = os.listdir(IMAGE_FOLDER)
files2 = os.listdir(MUSIC_FOLDER)
# Tenhle diddy blud skenuje složku vždecke když posílá žlincerald lebkalebkalebka
@@ -100,6 +113,23 @@ def send_random_image(message):
else:
bot.send_photo(message.chat.id, media)
#šludba
@bot.message_handler(commands=["hudba"])
def send_random_song(message):
chosen = random.choice(files2)
path = os.path.join(MUSIC_FOLDER, chosen)
with open(path, "rb") as media:
name = chosen.lower()
if name.endswith(AUDIO_EXT):
bot.send_audio(message.chat.id, media)
elif name.endswith(VIDEO_EXT):
bot.send_video(message.chat.id, media)
else:
bot.send_document(message.chat.id, media)
# https://github.com/oobabooga/text-generation-webui/wiki/12-%E2%80%90-OpenAI-API#chat-completions-with-characters
def llm_api_call(messages):