Php 类的声明必须与电报bot包中的接口错误兼容
我在用机器人打电报 但是,当我首先安装Php 类的声明必须与电报bot包中的接口错误兼容,php,telegram,telegram-bot,Php,Telegram,Telegram Bot,我在用机器人打电报 但是,当我首先安装dev develope时,我遇到了以下错误: Cannot use Telegram\Bot\Objects\Message as Message because the name is already in use {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 64): Cannot use Telegram\\
dev develope
时,我遇到了以下错误:
Cannot use Telegram\Bot\Objects\Message as Message because the name is already in use {"exception":"[object]
(Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 64): Cannot use Telegram\\Bot\\Objects\\Message as Message because the name is already in use at D:\\wamp\\www\\botshop\\vendor\\irazasyed\\telegram-bot-sdk\\src\\Methods\\Payments.php:5)
但在那之后,当我评论使用电报\Bot\Objects\Message时代码>位于的第5行,错误不再显示
但另一个问题是:
Declaration of App\Commands\StartCommand::handle($arguments) must be compatible with Telegram\Bot\Commands\Command::handle()
这是一个简单的StartCommand
,在创建新命令的所有示例中,它本身也使用该包:
class StartCommand extends Command
{
protected $name = "start";
protected $description = "Start Command to get you started";
public function handle($arguments)
{
$this->replyWithMessage(['text' => 'Hello! Welcome to our bot, Here are our available commands:']);
}
}
我使用的是php7.0.10和laravel5.5 默认情况下,handle
函数在电报\Bot\Commands\Command
类上不接受任何参数
由于您不使用$arguments
变量,因此可以从句柄
函数参数中删除该变量,您的代码应该可以再次工作。在我使用的版本3中,它在许多情况下都使用了$arguments
。在这种情况下,我必须删除这些参数,但如何发送自定义参数?请注意,我从未使用过此库,但从我在项目中查找的情况来看,此分支似乎有点不稳定和快速移动,这对于生产来说可能不是一个好主意。从他们使用的最新电报库来看,他们的文件似乎已经过时了。