此错误表示aiogram的refill_get()方法缺少一个必需的参数“message”,需要在使用该方法时传入一个“message”参数。
以下是添加“message”参数的示例代码:
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.types import Message
from aiogram.utils import executor
bot = Bot(token='YOUR_API_TOKEN_HERE')
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def start_command(message: Message):
with open('welcome.txt', 'r', encoding='utf-8') as file:
welcome_message = file.read()
await message.reply(welcome_message)
@dp.message_handler(commands=['help'])
async def help_command(message: Message):
with open('help.txt', 'r', encoding='utf-8') as file:
help_message = file.read()
await bot.send_message(chat_id=message.chat.id, text=help_message)
if __name__ == '__main__':
executor.start_polling(dp)
在message_handler中,定义了两个处理程序start_command和help_command。这两个处理程序都需要一个参数“message”。通过在函数定义中添加“message: Message”参数,可以解决refill_get()方法缺少“message”参数的问题。
上一篇:aiogrammessagehandlernotfiringforamessagecontainingmedia”
下一篇:aiogramrefill_get()missing1requiredpositionalargument:'message'