Closed
Description
Hi Guys, first off thanks for the good work.
However I'm running into an issue. I have tried following the tutorial in the wiki on how to create custom commands.
I'm trying to use a custom directory. However when I try to hook this custom path, none of the preset commands work and no response on my custom command. I have followed the naming conventions TestCommand.php etc.
Whenever I add my own TestCommand.php to your src in /vendor/autoload, none of the preset, nor my own command work.
Please help me. Excuse me for my bad grammar and markup.
Thanks in advance!
in my bot.php
$commands_path = __DIR__ .'/../Commands/';
$telegram->addCommandsPath($commands_path);
In my TestCommand.php in /../Commands/
<?php
namespace Longman\TelegramBot\Commands;
require __DIR__ . '/../vendor/autoload.php';
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Entities\Update;
class TestCommand extends Command
{
protected $name = 'test'; //your command's name
protected $description = 'Send test message'; //Your command description
protected $usage = '/test'; // Usage of your command
//protected $version = '1.0.0';
protected $enabled = true;
//protected $public = true;
public function execute()
{
$update = $this->getUpdate(); //get Updates
$message = $this->getMessage(); // get Message info
//$chatId = '9767300';
$chat_id = $message->getChat()->getId(); //Get Chat Id
$message_id = $message->getMessageId(); //Get message Id
//$text = $message->getText(true); //Get recieved text
$data = array(); // prepapre $data
$data['chat_id'] = $chat_id; //set chat Id
$data['reply_to_message_id'] = $message_id; //set message Id
$data['text'] = 'This is just a Test...'; //set reply message
$result = Request::sendMessage($data); //send message
return $result;
}
}
?>
Metadata
Metadata
Assignees
Labels
No labels