Загрузка...

Help please

Thread in Python created by Hasan808_TNT Dec 3, 2024. 159 views

  1. Hasan808_TNT
    Hasan808_TNT Topic starter Dec 3, 2024 1 Feb 22, 2023
    Ошибка:
    AttributeError: 'NoneType' object has no attribute 'id'

    Python
    import asyncio

    import logging

    import config # Ваш файл конфигурации

    from aiogram import Bot, Dispatcher, executor, types

    from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton

    from aiocryptopay import AioCryptoPay, Networks

    # Инициализация бота и других объектов

    bot = Bot(token=config.TOKEN, parse_mode='HTML')

    dp = Dispatcher(bot)

    cryptopay = AioCryptoPay(config.CRYPTO_TOKEN, network=Networks.MAIN_NET)

    async def handle_dice(message, bet_usd, bet_comment, player_id):

    dice_value = (await bot.send_dice(chat_id=config.MAIN_ID)).dice.value

    bet_type = bet_comment.split(" ")[1].lower()

    win_amount = bet_usd * config.cef if (bet_type == "меньше" and dice_value in [1, 2, 3]) or (bet_type == "больше" and dice_value in [4, 5, 6]) else 0

    if win_amount:

    try:

    await pay_money(win_amount, player_id)

    await bot.send_photo(chat_id=config.MAIN_ID, photo=open("img/win.png", "rb"),

    caption=f"<b> Поздравляем, вы выиграли {win_amount}$!</b>\n\n<blockquote><b> Ваш выигрыш успешно отправлен чеком боту https://t.me/Crypto_Casinosbot</b></blockquote>")

    except Exception as e:

    logging.error(f"Ошибка при выплате: {e}")

    await notify_admin_of_error(win_amount, player_id)

    else:

    await bot.send_photo(chat_id=config.MAIN_ID, photo=open("img/lose.png", "rb"),

    caption="<blockquote><b>❌ | К сожалению, вы проиграли.</b></blockquote>")

    async def handle_error(message, error_message):

    player_name = message.text.split("отправил(а)")[0].strip()

    await bot.send_message(config.MAIN_ID,

    f"<b>[⛔] Ошибка!</b>\n\n<blockquote><b>{error_message}\nНапишите администратору @HasanPOM за возвратом.</b></blockquote>")

    async def notify_admin_of_error(win_amount, player_id):

    await bot.send_photo(chat_id=config.MAIN_ID, photo=open("img/win.png", "rb"),

    caption=f"<blockquote><b> Поздравляем, вы выиграли {win_amount}, но вы не зарегистрированы в боте: https://t.me/Crypto_Casinosbot. Напишите в ЛС одному из Админа!</b></blockquote>")

    @dp.message_handler(commands=['start'])

    async def send_welcome(message: types.Message):

    await message.reply("[] Привет! Спасибо что выбрали нас!")

    @dp.channel_post_handler(chat_id=int(config.PAY_ID))

    async def handle_new_bet(message: types.Message):

    try:

    bet_usd = float(message.text.split("($")[1].split(").")[0].replace(',', ''))

    bet_comment = message.text.split(" ")[1].lower()

    player_name = message.text.split("отправил(а)")[0].strip()

    user = message.entities[0].user

    player_id = user.id

    keyboard = InlineKeyboardMarkup().add(InlineKeyboardButton(text="Сделать ставку", url=config.pinned_link))

    bet_design = config.bet.format(bet_usd=bet_usd, player_name=player_name, bet_comment=bet_comment)

    if bet_comment.startswith("куб") and bet_comment in config.ag_dice:

    await handle_dice(message, bet_usd, bet_comment, player_id)

    else:

    await bot.send_message(config.MAIN_ID,

    "<blockquote><b> | Вы указали неверную игру!\n\n | Для получения средств обратно, напишите Админам из описания канала.</b></blockquote>")

    except IndexError:

    await handle_error(message, "Игрок не указал комментарий!")

    except Exception as e:

    logging.exception("Произошла ошибка")

    await bot.send_message(config.MAIN_ID, "<b>[⛔] Произошла неизвестная ошибка при обработке ставки!</b>")

    if __name__ == '__main__':

    executor.start_polling(dp, skip_updates=True)
     
    1. View previous comments (6)
    2. Апатия
      Hasan808_TNT, [IMG]
      вот это на таб подними, чтобы в if тоже была
    3. Hasan808_TNT Topic starter
    4. Hasan808_TNT Topic starter
  2. Hasan808_TNT
    Hasan808_TNT Topic starter Dec 3, 2024 1 Feb 22, 2023
    Вот тепер это он
    The post was merged to previous Dec 3, 2024
    А что делать я ваше не понимаю я ваше тупой ббез мозгов :nerd:
     
    1. Getrequest
      Hasan808_TNT, ну этот код же с чатгпт написал, так и продолжи писать с него
  3. lMixFixl
    lMixFixl Dec 3, 2024 1056 Apr 15, 2017
     
    1. Hasan808_TNT Topic starter
      lMixFixl, Всë равно такая ошибка
Top
Loading...