commit 877fc7f6d5284582c9401997963f23070dfb8a41 Author: Prosto123 Date: Sun Feb 23 10:55:58 2025 +0100 init Инициализация проекта на гите diff --git a/config.py b/config.py new file mode 100644 index 0000000..84985f3 --- /dev/null +++ b/config.py @@ -0,0 +1,4 @@ +TOKEN = "7793209318:AAEp2F1_rrTaCM893E2i4y98ruS9ToFTJk0" +admin_id = "1761844855" +############################################################# + diff --git a/main.py b/main.py new file mode 100644 index 0000000..c1ef1d0 --- /dev/null +++ b/main.py @@ -0,0 +1,171 @@ +import telebot +import config +from telebot import types +import os + +bot = telebot.TeleBot(token=config.TOKEN) + +heroes = { + "Сила": [ + "Alchemist", "Axe", "Bristleback", "Centaur Warrunner", "Chaos Knight", "Dawnbreaker", "Doom", + "Dragon Knight", "Earth Spirit", "Earthshaker", "Elder Titan", "Huskar", "Kunkka", "Legion Commander", + "Lifestealer", "Mars", "Night Stalker", "Ogre Magi", "Omniknight", "Primal Beast", "Pudge", "Slardar", + "Spirit Breaker", "Sven", "Tidehunter", "Tiny", "Treant Protector", "Tusk", "Underlord", "Undying", + "Wraith King" + ], + "Ловкость": [ + "Anti-Mage", "Arc Warden", "Bloodseeker", "Bounty Hunter", "Clinkz", "Drow Ranger", "Ember Spirit", + "Faceless Void", "Gyrocopter", "Hoodwink", "Juggernaut", "Luna", "Medusa", "Meepo", "Monkey King", + "Morphling", "Naga Siren", "Phantom Assassin", "Phantom Lancer", "Razor", "Riki", "Shadow Fiend", "Sniper", + "Spectre", "Templar Assassin", "Terrorblade", "Troll Warlord", "Ursa", "Viper", "Weaver" + ], + "Интеллект": [ + "Ancient Apparition", "Crystal Maiden", "Death Prophet", "Disruptor", "Enchantress", "Grimstroke", "Jakiro", + "Keeper of the Light", "Leshrac", "Lich", "Lina", "Lion", "Muerta", "Nature Prophet", "Necrophos", "Oracle", + "Outworld Destroyer", "Puck", "Pugna", "Queen of Pain", "Rubick", "Shadow Demon", "Shadow Shaman", "Silencer", + "Skywrath Mage", "Storm Spirit", "Tinker", "Warlock", "Witch Doctor", "Zeus" + ], + "Универсальность": [ + "Abaddon", "Bane", "Batrider", "Beastmaster", "Brewmaster", "Broodmother", "Chen", "Clockwerk", "Dark Seer", + "Dark Willow", "Dazzle", "Enigma", "Invoker", "Io", "Lone Druid", "Lycan", "Magnus", "Marci", "Mirana", + "Nyx Assassin", "Pangolier", "Phoenix", "Sand King", "Snapfire", "Techies", "Timbersaw", "Vengeful Spirit", + "Venomancer", "Visage", "Void Spirit", "Windranger", "Winter Wyvern" + ] +} + +# Сборки предметов для каждого героя +builds = { + "Alchemist": { + "Магический": ["Нет такой сборки"], + "Физический": ["Radiance", "Blink Dagger", "Butterfly", "Assault Cuirass", "Moon Shard", "Monkey King Bar"] + }, + "Axe": { + "Магический": ["Нет такой сборки"], + "Физический": ["Blade Mail", "Blink Dagger", "Bloodstone", "Kaya and Sange", "", ""] + }, + "Bristleback": { + "Магический": ["Bloodstone", "Aghanim Scepter", "Sange and Yasha", "Shiva's Guard", "Black King Bar", "Blink Dagger"], + "Физический": ["Abyssal BLade", "Heart Of Tarrasque", "Blade Mail", "Bloodstone", "Ethernal Shroud", "Aghanim Scepter"] + }, + "Centaur Warrunner": { + "Магический": ["Нет такой сборки"], + "Физический": ["Boots of travel", "Blink Dagger", "Shiva's Guard", "Heart of Tarrasque", "Blade Mail ", "Assault Curiass"] + }, + "Chaos Knight": { + "Магический": ["Нет такой сборки"], + "Физический": ["Harpoon", "Manta Style", "Shadow Blade ", "Bloodthorn", "Satanic ", " Abyssal Blade"] + }, + "DawnBreaker": { + "Магический": ["Нет такой сборки"], + "Физический": ["Black King Bar", "Blink Dagger", "Harpoon", "Blade Mail", "Deadalus", "Aghanim's Scepter"] + }, + "Doom": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["Aghanim's Scepter ", "Heart of Tarrasque", "Shiva's Guard", "Blink Dagger", "Black king Bar", "Refresher Or"] + }, + "Dragon Knight": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "Earth Spirit": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "Earthshaker": { + "Магический": ["Blink Dagger", "Aghanim's Scepter", "Octarine Ord", "Refresher Orb", "Scythe of Vyse", "Sange and Kaya"], + "Физический": ["Deadalus", "Aghanim's Scepter", "Harpoon", "Abyssal Blade", "Black King Bar", "Sange and Yasha"] + }, + "Elder Titan": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "Huskar": { + "Магический": ["Eternal Blade", "Dagon", "Yasha and Kaya", "Khanda", "Aghanim's Scepter", "Blink Dagger"], + "Физический": ["Satanic", "Heart of Tarrasque", "Armlet of Mordiggian", "Sange and Yasha", "Heaven's Halberd", "Aghanim's Scepter"] + }, + "Kunkka": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "Legion Commander": { + "Магический": ["Нет такой сборки"], + "Физический": ["Blade Mail", "Blink Dagger", "Deadalus", "Deasolator", "Assault Curiass", "Aghanim's Shard, Aghanim's Scepter"] + }, + "Lifestealer": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "Mars": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + "": { + "Магический": [" ", " ", " ", " ", " ", " "], + "Физический": ["", "", "", "", "", ""] + }, + + +} + + +# Путь к изображениям героев +IMAGES_PATH = 'images/' + +# Функция для создания списка героев с гиперссылками +def create_hero_links(heroes_list): + links = [] + for hero in heroes_list: + link = f"[{hero}](https://www.dota2.com/heroes/{hero.lower().replace(' ', '-')})" + links.append(link) + return "\n".join(links) + +@bot.message_handler(commands=['start']) +def start(message): + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + btn_strength = types.KeyboardButton("Сила") + btn_agility = types.KeyboardButton("Ловкость") + btn_intelligence = types.KeyboardButton("Интеллект") + btn_universal = types.KeyboardButton("Универсальность") + markup.add(btn_strength, btn_agility, btn_intelligence, btn_universal) + bot.send_message(message.chat.id, "Выберите атрибут героя:", reply_markup=markup) + +@bot.message_handler(func=lambda message: message.text in ["Сила", "Ловкость", "Интеллект", "Универсальность"]) +def send_heroes(message): + attribute = message.text + hero_list = heroes.get(attribute, []) + if hero_list: + response = f"Герои с атрибутом {attribute}:\n" + create_hero_links(hero_list) + bot.send_message(message.chat.id, response, parse_mode="Markdown") + else: + bot.send_message(message.chat.id, "Нет героев с таким атрибутом.") + +@bot.message_handler(func=lambda message: message.text in heroes["Сила"] + heroes["Ловкость"] + heroes["Интеллект"] + heroes["Универсальность"]) +def send_item_buttons(message): + hero_name = message.text + markup = types.ReplyKeyboardMarkup(resize_keyboard=True) + btn_magic = types.KeyboardButton("Магический") + btn_physical = types.KeyboardButton("Физический") + markup.add(btn_magic, btn_physical) + bot.send_message(message.chat.id, f"Вы выбрали героя: {hero_name}\nВыберите тип предметов:", reply_markup=markup) + bot.register_next_step_handler(message, lambda m: send_build(m, hero_name)) + +def send_build(message, hero_name): + item_type = message.text + if item_type not in ["Магический", "Физический"]: + bot.send_message(message.chat.id, "Пожалуйста, выберите корректный тип предметов.") + return + + build = builds.get(hero_name, {}).get(item_type, []) + if not build: + bot.send_message(message.chat.id, "Сборка для данного героя и типа предметов недоступна.") + return + + image_path = os.path.join(IMAGES_PATH, f"{hero_name}.png") + + if os.path.exists(image_path): + with open(image_path, 'rb') as img: + bot.send_photo(message.chat.id, img, caption=f"Имя героя: {hero_name}\nТип предметов: {item_type}\nПредметы:\n" + "\n".join(build)) + else: + bot.send_message(message.chat.id, f"Имя героя: {hero_name}\nТип предметов: {item_type}\nПредметы:\n" + "\n".join(build)) + +bot.polling()