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
fc2a8ca6
Commit
fc2a8ca6
authored
Aug 11, 2015
by
Avtandil Kikabidze
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21 from MBoretto/master
Help Command and new chat participant work
parents
5924a7f1
4eef4d40
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
43 deletions
+37
-43
HelpCommand.php
src/Commands/HelpCommand.php
+10
-7
KeyboardCommand.php
src/Commands/KeyboardCommand.php
+14
-14
LeftchatparticipantCommand.php
src/Commands/LeftchatparticipantCommand.php
+1
-1
NewchatparticipantCommand.php
src/Commands/NewchatparticipantCommand.php
+1
-1
Telegram.php
src/Telegram.php
+11
-20
No files found.
src/Commands/HelpCommand.php
View file @
fc2a8ca6
...
@@ -33,10 +33,12 @@ class HelpCommand extends Command
...
@@ -33,10 +33,12 @@ class HelpCommand extends Command
$text
=
$message
->
getText
(
true
);
$text
=
$message
->
getText
(
true
);
$commands
=
$this
->
telegram
->
getCommandsList
();
$commands
=
$this
->
telegram
->
getCommandsList
();
if
(
empty
(
$text
))
{
if
(
empty
(
$text
))
{
$msg
=
'GeoBot v. '
.
$this
->
telegram
->
getVersion
()
.
"
\n\n
"
;
$msg
=
'GeoBot v. '
.
$this
->
telegram
->
getVersion
()
.
"
\n\n
"
;
$msg
.=
'Commands List:'
.
"
\n
"
;
$msg
.=
'Commands List:'
.
"
\n
"
;
foreach
(
$commands
as
$command
)
{
foreach
(
$commands
as
$command
)
{
if
(
is_object
(
$command
))
{
if
(
!
$command
->
isEnabled
())
{
if
(
!
$command
->
isEnabled
())
{
continue
;
continue
;
}
}
...
@@ -46,6 +48,7 @@ class HelpCommand extends Command
...
@@ -46,6 +48,7 @@ class HelpCommand extends Command
$msg
.=
'/'
.
$command
->
getName
()
.
' - '
.
$command
->
getDescription
()
.
"
\n
"
;
$msg
.=
'/'
.
$command
->
getName
()
.
' - '
.
$command
->
getDescription
()
.
"
\n
"
;
}
}
}
$msg
.=
"
\n
"
.
'For exact command help type: /help <command>'
;
$msg
.=
"
\n
"
.
'For exact command help type: /help <command>'
;
}
else
{
}
else
{
...
...
src/Commands/KeyboardCommand.php
View file @
fc2a8ca6
...
@@ -47,28 +47,28 @@ class KeyboardCommand extends Command
...
@@ -47,28 +47,28 @@ class KeyboardCommand extends Command
$keyboards
=
array
();
$keyboards
=
array
();
//0
//0
$keyboard
[
0
]
=
array
(
'7'
,
'8'
,
'9'
)
;
$keyboard
[
]
=
[
'7'
,
'8'
,
'9'
]
;
$keyboard
[
1
]
=
array
(
'4'
,
'5'
,
'6'
)
;
$keyboard
[
]
=
[
'4'
,
'5'
,
'6'
]
;
$keyboard
[
2
]
=
array
(
'1'
,
'2'
,
'3'
)
;
$keyboard
[
]
=
[
'1'
,
'2'
,
'3'
]
;
$keyboard
[
3
]
=
array
(
' '
,
'0'
,
' '
)
;
$keyboard
[
]
=
[
' '
,
'0'
,
' '
]
;
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
unset
(
$keyboard
);
//1
//1
$keyboard
[
0
]
=
array
(
'7'
,
'8'
,
'9'
,
'+'
)
;
$keyboard
[
]
=
[
'7'
,
'8'
,
'9'
,
'+'
]
;
$keyboard
[
1
]
=
array
(
'4'
,
'5'
,
'6'
,
'-'
)
;
$keyboard
[
]
=
[
'4'
,
'5'
,
'6'
,
'-'
]
;
$keyboard
[
2
]
=
array
(
'1'
,
'2'
,
'3'
,
'*'
)
;
$keyboard
[
]
=
[
'1'
,
'2'
,
'3'
,
'*'
]
;
$keyboard
[
3
]
=
array
(
' '
,
'0'
,
' '
,
'/'
)
;
$keyboard
[
]
=
[
' '
,
'0'
,
' '
,
'/'
]
;
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
unset
(
$keyboard
);
//2
//2
$keyboard
[
0
]
=
array
(
'A'
)
;
$keyboard
[
]
=
[
'A'
]
;
$keyboard
[
1
]
=
array
(
'B'
)
;
$keyboard
[
]
=
[
'B'
]
;
$keyboard
[
2
]
=
array
(
'C'
)
;
$keyboard
[
]
=
[
'C'
]
;
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
unset
(
$keyboard
);
...
@@ -76,9 +76,9 @@ class KeyboardCommand extends Command
...
@@ -76,9 +76,9 @@ class KeyboardCommand extends Command
//3
//3
$keyboard
[
0
]
=
array
(
'A'
)
;
$keyboard
[
]
=
[
'A'
]
;
$keyboard
[
1
]
=
array
(
'B'
)
;
$keyboard
[
]
=
[
'B'
]
;
$keyboard
[
2
]
=
array
(
'C'
,
'D'
)
;
$keyboard
[
]
=
[
'C'
,
'D'
]
;
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
unset
(
$keyboard
);
...
...
src/Commands/Left
ChatP
articipantCommand.php
→
src/Commands/Left
chatp
articipantCommand.php
View file @
fc2a8ca6
...
@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
...
@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\Update
;
class
Left
ChatP
articipantCommand
extends
Command
class
Left
chatp
articipantCommand
extends
Command
{
{
protected
$name
=
'left_chat_participant'
;
protected
$name
=
'left_chat_participant'
;
protected
$description
=
'Left Chat Participant'
;
protected
$description
=
'Left Chat Participant'
;
...
...
src/Commands/New
ChatP
articipantCommand.php
→
src/Commands/New
chatp
articipantCommand.php
View file @
fc2a8ca6
...
@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
...
@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\Update
;
class
New
ChatP
articipantCommand
extends
Command
class
New
chatp
articipantCommand
extends
Command
{
{
protected
$name
=
'new_chat_participant'
;
protected
$name
=
'new_chat_participant'
;
protected
$description
=
'New Chat Participant'
;
protected
$description
=
'New Chat Participant'
;
...
...
src/Telegram.php
View file @
fc2a8ca6
...
@@ -189,9 +189,12 @@ class Telegram
...
@@ -189,9 +189,12 @@ class Telegram
continue
;
continue
;
}
}
$name
=
$fileInfo
->
getFilename
();
$name
=
$fileInfo
->
getFilename
();
if
(
substr
(
$name
,
-
11
,
11
)
===
'Command.php'
)
{
$name
=
strtolower
(
str_replace
(
'Command.php'
,
''
,
$name
));
$name
=
strtolower
(
str_replace
(
'Command.php'
,
''
,
$name
));
$commands
[
$name
]
=
$this
->
getCommandClass
(
$name
);
$commands
[
$name
]
=
$this
->
getCommandClass
(
$name
);
}
}
}
if
(
!
empty
(
$this
->
commands_dir
))
{
if
(
!
empty
(
$this
->
commands_dir
))
{
foreach
(
$this
->
commands_dir
as
$dir
)
{
foreach
(
$this
->
commands_dir
as
$dir
)
{
...
@@ -204,12 +207,13 @@ class Telegram
...
@@ -204,12 +207,13 @@ class Telegram
continue
;
continue
;
}
}
$name
=
$fileInfo
->
getFilename
();
$name
=
$fileInfo
->
getFilename
();
if
(
substr
(
$name
,
-
11
,
11
)
===
'Command.php'
)
{
$name
=
strtolower
(
str_replace
(
'Command.php'
,
''
,
$name
));
$name
=
strtolower
(
str_replace
(
'Command.php'
,
''
,
$name
));
$commands
[
$name
]
=
$this
->
getCommandClass
(
$name
);
$commands
[
$name
]
=
$this
->
getCommandClass
(
$name
);
}
}
}
}
}
}
}
return
$commands
;
return
$commands
;
}
}
...
@@ -295,7 +299,6 @@ class Telegram
...
@@ -295,7 +299,6 @@ class Telegram
default
:
default
:
case
'text'
:
case
'text'
:
// do nothing
// do nothing
break
;
break
;
case
'command'
:
case
'command'
:
...
@@ -306,42 +309,30 @@ class Telegram
...
@@ -306,42 +309,30 @@ class Telegram
case
'new_chat_participant'
:
case
'new_chat_participant'
:
// trigger new participant
// trigger new participant
$command
=
'new_chat_participant'
;
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
=
'left_chat_participant'
;
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
break
;
break
;
case
'delete_chat_photo'
:
case
'delete_chat_photo'
:
// trigger delete_chat_photo
// trigger delete_chat_photo
break
;
break
;
case
'group_chat_created'
:
case
'group_chat_created'
:
// trigger group_chat_created
// trigger group_chat_created
break
;
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