Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
33112c89
Commit
33112c89
authored
Sep 26, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing GenericmessageCommand.php
parent
441f32de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
19 deletions
+45
-19
GenericCommand.php
src/Commands/GenericCommand.php
+1
-1
GenericmessageCommand.php
src/Commands/GenericmessageCommand.php
+37
-0
Telegram.php
src/Telegram.php
+7
-18
No files found.
src/Commands/GenericCommand.php
View file @
33112c89
...
...
@@ -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 gen
e
ric commands or is executed by default when a command is not found'
;
protected
$usage
=
'/'
;
protected
$version
=
'1.0.0'
;
protected
$enabled
=
true
;
...
...
src/Commands/GenericmessageCommand.php
0 → 100644
View file @
33112c89
<?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
}
}
src/Telegram.php
View file @
33112c89
...
...
@@ -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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment