Вопрос по pyrofork нужно, чтобы отправлялся текс в описании подарка при отправке text="текст" выдает ошибку Error: object of type 'NoneType' has no len() помогите как пофиксить
Посмотри где ты len вызываешь и там уже разбирайся. Твоя подсказочка насчет text="текст" ничего нам не дает. Вообще если хочешь быстренько решить проблему, то хотя бы часть кода скинь
ksv3000, Окей, давай намекну еще раз. Скинь код. Не юзается внутри этой функции пирофорка len, ты где-то насрал
logging.basicConfig(level=logging.INFO, format='%(asctime)s - [SENDER] - %(levelname)s - %(message)s', handlers=[logging.FileHandler('bot.log', encoding='utf-8'), logging.StreamHandler(sys.stdout)]) API_ID = API_HASH = SESSION_NAME = "pyrofork_sender_session" TASK_FILE = 'task.txt' GIFT_CONFIG = { 'standard': {'id': 5170233102089322756}, 'special_21': {'id': 5170250947678437525}, 'new_gift_43': {'id': 5170144170496491616}, # Новый подарок #1 'new_gift_85': {'id': 5168043875654172773} # Новый подарок #2 } app = Client(SESSION_NAME, api_id=API_ID, api_hash=API_HASH) async def send_gift_action(recipient_username, gift_type): try: gift_info = GIFT_CONFIG.get(gift_type) if not gift_info or not isinstance(gift_info['id'], int): logging.error(f"Gift '{gift_type}' is not configured correctly.") return False logging.info(f" Sending gift '{gift_type}' to @{recipient_username}...") await app.send_gift( chat_id=recipient_username, text="text", gift_id=gift_info['id'] ) logging.info(f" Successfully sent gift to @{recipient_username}") return True except Exception as e: logging.error(f" Failed to send gift to @{recipient_username}. Error: {e}") return False async def main(): logging.info("Sender bot starting...") await app.start() me = await app.get_me() logging.info(f"Logged in as {me.first_name}. Polling for tasks...") while True: try: if os.path.exists(TASK_FILE) and os.path.getsize(TASK_FILE) > 0: logging.info("New task found in task.txt!") with open(TASK_FILE, 'r+', encoding='utf-8') as f: try: task_data = json.load(f) except json.JSONDecodeError: logging.warning("task.txt is corrupted or being written to. Skipping this check.") continue username = task_data.get("username") gift_type = task_data.get("gift_type") count = task_data.get("count") logging.info(f"Executing task: {count} gift(s) of type '{gift_type}' for @{username}") for i in range(count): logging.info(f"-> Sending gift {i+1}/{count}...") success = await send_gift_action(username, gift_type) if not success: logging.error(f"Stopping order for @{username} due to a sending error.") break if i < count - 1: logging.info("Pausing for 5 seconds before next gift...") await asyncio.sleep(5) f.seek(0) f.truncate() logging.info("Task finished and task.txt cleared.") await asyncio.sleep(3) except Exception as e: logging.error(f"An error occurred in the sender loop: {e}") await asyncio.sleep(10) if __name__ == '__main__': try: asyncio.run(main()) except (KeyboardInterrupt, SystemExit): logging.info("Sender bot stopped by user.") finally: if app.is_initialized: asyncio.run(app.stop()) logging.info("Sender has been shut down.")