A
A
Adyl Abdinazarov2021-06-25 20:57:13
Python
Adyl Abdinazarov, 2021-06-25 20:57:13

How to send audio using user bot?

I have a user bot with personal commands in it. And I want to make it so that when I enter a command, it sends the prepared text and audio file from my computer. It sends the text, but trying to send audio in the console gives the error "AttributeError: 'Message' object has no attribute 'send_audio'". Although I did everything strictly according to the instructions and checked everything against the information about the library (pyrogram) on github. If anyone has encountered this problem or knows how to solve it, please help.

from pyrogram import Client, filters
from pyrogram.errors import FloodWait 
from pyrogram.types import ChatPermissions 
import time
from time import sleep
import random
 
app = Client("my_account")

@app.on_message(filters.command("idi", prefixes=".") & filters.me)
def idi(_, msg):
    orig_text = msg.text.split(".idi ", maxsplit=1)[1]
    text = orig_text
    tbp = "" 


    while(tbp != orig_text):
        try:
            msg.edit("отстань от меня")
            msg.send_audio("C:/Users/User/Desktop/BOTS/user_bot/idi.mp3", 'rb')
 
            tbp = tbp + text[0]
            text = text[1:]
 
        except FloodWait as e:
            sleep(e.x)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question