Commit 33112c89 authored by MBoretto's avatar MBoretto

Introducing GenericmessageCommand.php

parent 441f32de
...@@ -17,7 +17,7 @@ use Longman\TelegramBot\Entities\Update; ...@@ -17,7 +17,7 @@ use Longman\TelegramBot\Entities\Update;
class GenericCommand extends Command class GenericCommand extends Command
{ {
protected $name = 'Generic'; 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 $usage = '/';
protected $version = '1.0.0'; protected $version = '1.0.0';
protected $enabled = true; 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 ...@@ -30,7 +30,7 @@ class Telegram
* *
* @var string * @var string
*/ */
protected $version = '0.17.2'; protected $version = '0.17.3';
/** /**
* Telegram API key * Telegram API key
...@@ -372,43 +372,32 @@ class Telegram ...@@ -372,43 +372,32 @@ class Telegram
switch ($type) { switch ($type) {
default: default:
case 'text': case 'text':
// do nothing return $this->executeCommand('Genericmessage', $update);
break; break;
case 'command': case 'command':
// execute command // execute command
$command = $message->getCommand(); $command = $message->getCommand();
return $this->executeCommand($command, $update); return $this->executeCommand($command, $update);
break; break;
case 'new_chat_participant': case 'new_chat_participant':
// trigger new participant // trigger new participant
$command = 'Newchatparticipant'; return $this->executeCommand('Newchatparticipant', $update);
return $this->executeCommand($command, $update);
break; break;
case 'left_chat_participant': case 'left_chat_participant':
// trigger left chat participant // trigger left chat participant
$command = 'Leftchatparticipant'; return $this->executeCommand('Leftchatparticipant', $update);
return $this->executeCommand($command, $update);
break; break;
case 'new_chat_title': case 'new_chat_title':
// trigger new_chat_title // trigger new_chat_title
$command = 'Newchattitle'; return $this->executeCommand('Newchattitle', $update);
return $this->executeCommand($command, $update);
break; break;
case 'delete_chat_photo': case 'delete_chat_photo':
// trigger delete_chat_photo // trigger delete_chat_photo
$command = 'Deletechatphoto'; return $this->executeCommand('Deletechatphoto', $update);
return $this->executeCommand($command, $update);
break; break;
case 'group_chat_created': case 'group_chat_created':
// trigger group_chat_created // trigger group_chat_created
$command = 'Groupchatcreated'; return $this->executeCommand('Groupchatcreated', $update);
return $this->executeCommand($command, $update);
break; 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