Commit 33112c89 authored by MBoretto's avatar MBoretto

Introducing GenericmessageCommand.php

parent 441f32de
......@@ -17,7 +17,7 @@ use Longman\TelegramBot\Entities\Update;
class GenericCommand extends Command
{
protected $name = 'Generic';
protected $description = 'Handle genric commands or is executed by default when a command is not found';
protected $description = 'Handle generic commands or is executed by default when a command is not found';
protected $usage = '/';
protected $version = '1.0.0';
protected $enabled = true;
......
<?php
/*
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;
class GenericmessageCommand extends Command
{
protected $name = 'Genericmessage';
protected $description = 'Handle generic message';
protected $usage = '/';
protected $version = '1.0.0';
protected $enabled = true;
public function execute()
{
$update = $this->getUpdate();
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
//you can use $command as param
$command = $message->getCommand();
$chat_id = $message->getChat()->getId();
$text = $message->getText(true);
//Do nothing
}
}
......@@ -30,7 +30,7 @@ class Telegram
*
* @var string
*/
protected $version = '0.17.2';
protected $version = '0.17.3';
/**
* Telegram API key
......@@ -372,43 +372,32 @@ class Telegram
switch ($type) {
default:
case 'text':
// do nothing
return $this->executeCommand('Genericmessage', $update);
break;
case 'command':
// execute command
$command = $message->getCommand();
return $this->executeCommand($command, $update);
break;
case 'new_chat_participant':
// trigger new participant
$command = 'Newchatparticipant';
return $this->executeCommand($command, $update);
return $this->executeCommand('Newchatparticipant', $update);
break;
case 'left_chat_participant':
// trigger left chat participant
$command = 'Leftchatparticipant';
return $this->executeCommand($command, $update);
return $this->executeCommand('Leftchatparticipant', $update);
break;
case 'new_chat_title':
// trigger new_chat_title
$command = 'Newchattitle';
return $this->executeCommand($command, $update);
return $this->executeCommand('Newchattitle', $update);
break;
case 'delete_chat_photo':
// trigger delete_chat_photo
$command = 'Deletechatphoto';
return $this->executeCommand($command, $update);
return $this->executeCommand('Deletechatphoto', $update);
break;
case 'group_chat_created':
// trigger group_chat_created
$command = 'Groupchatcreated';
return $this->executeCommand($command, $update);
return $this->executeCommand('Groupchatcreated', $update);
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment