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
e44202be
Commit
e44202be
authored
Jul 18, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Uptodate reply markup tipes
parent
e41966bb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
25 deletions
+170
-25
ForcereplyCommand.php
src/Commands/ForcereplyCommand.php
+13
-6
HidekeyboardCommand.php
src/Commands/HidekeyboardCommand.php
+12
-5
KeyboardCommand.php
src/Commands/KeyboardCommand.php
+52
-14
ForceReply.php
src/Entities/ForceReply.php
+25
-0
ReplyKeyboardHide.php
src/Entities/ReplyKeyboardHide.php
+25
-0
ReplyKeyboardMarkup.php
src/Entities/ReplyKeyboardMarkup.php
+43
-0
No files found.
src/Commands/ForcereplyCommand.php
View file @
e44202be
...
...
@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\ReplyMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
ForceReplyCommand
extends
Command
{
...
...
@@ -38,14 +41,18 @@ class ForceReplyCommand extends Command
$data
[
'text'
]
=
'Write something:'
;
#$data['reply_to_message_id'] = $message_id;
$markup
=
new
ReplyMarkup
;
//$markup->addForceReply($selective = false)
$markup
->
addForceReply
(
false
);
$json
=
(
new
ForceReply
(
array
(
'selective'
=>
false
)
)
)
->
toJSON
();
$json
=
$markup
->
getJsonQuery
()
;
#echo $json
;
$data
[
'reply_markup'
]
=
$json
;
$result
=
Request
::
sendMessage
(
$data
);
return
$result
;
}
...
...
src/Commands/HidekeyboardCommand.php
View file @
e44202be
...
...
@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\ReplyMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
HidekeyboardCommand
extends
Command
{
...
...
@@ -38,10 +41,14 @@ class HidekeyboardCommand extends Command
$data
[
'text'
]
=
'Keyboard Hided'
;
#$data['reply_to_message_id'] = $message_id;
$markup
=
new
ReplyMarkup
;
//$markup->addKeyBoardHide($selective = false){
$markup
->
addKeyBoardHide
(
false
);
$json
=
$markup
->
getJsonQuery
();
$json
=
(
new
ReplyKeyBoardHide
(
array
(
'selective'
=>
false
)
)
)
->
toJSON
();
$data
[
'reply_markup'
]
=
$json
;
$result
=
Request
::
sendMessage
(
$data
);
...
...
src/Commands/KeyboardCommand.php
View file @
e44202be
...
...
@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\ReplyMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
KeyboardCommand
extends
Command
{
...
...
@@ -39,24 +42,59 @@ class KeyboardCommand extends Command
#$data['reply_to_message_id'] = $message_id;
$markup
=
new
ReplyMarkup
;
//$markup->addKeyBoard($options,$resize=false,$once=false,$selective=false)
//onother keyboard example
#$markup->addKeyBoard(array('A','B','C'),true,false,false);
//onother keyboard example
#$markup->addKeyBoard(array('A',array('B','B1'),'C'),true,false,false);
#Keyboard examples
$keyboards
=
array
();
//0
$keyboard
[
0
]
=
array
(
'7'
,
'8'
,
'9'
);
$keyboard
[
1
]
=
array
(
'4'
,
'5'
,
'6'
);
$keyboard
[
2
]
=
array
(
'1'
,
'2'
,
'3'
);
$keyboard
[
3
]
=
array
(
' '
,
'0'
,
' '
);
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//1
$keyboard
[
0
]
=
array
(
'7'
,
'8'
,
'9'
,
'+'
);
$keyboard
[
1
]
=
array
(
'4'
,
'5'
,
'6'
,
'-'
);
$keyboard
[
2
]
=
array
(
'1'
,
'2'
,
'3'
,
'*'
);
$keyboard
[
3
]
=
array
(
' '
,
'0'
,
' '
,
'/'
);
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//2
$keyboard
[
0
]
=
array
(
'A'
);
$keyboard
[
1
]
=
array
(
'B'
);
$keyboard
[
2
]
=
array
(
'C'
);
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//3
$keyboard
[
0
]
=
array
(
'A'
);
$keyboard
[
1
]
=
array
(
'B'
);
$keyboard
[
2
]
=
array
(
'C'
,
'D'
);
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
$markup
->
addKeyBoard
(
array
(
array
(
'7'
,
'8'
,
'9'
),
array
(
'4'
,
'5'
,
'6'
),
array
(
'1'
,
'2'
,
'3'
),
array
(
'0'
)
),
true
,
false
,
false
);
$json
=
$markup
->
getJsonQuery
();
$json
=
(
new
ReplyKeyboardMarkup
(
array
(
'keyboard'
=>
$keyboards
[
1
]
,
'resize_keyboard'
=>
true
,
'one_time_keyboard'
=>
false
,
'selective'
=>
false
)
)
)
->
toJSON
();
#echo $json;
$data
[
'reply_markup'
]
=
$json
;
$result
=
Request
::
sendMessage
(
$data
);
...
...
src/Entities/ForceReply.php
0 → 100644
View file @
e44202be
<?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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ForceReply
extends
Entity
{
protected
$force_reply
;
protected
$selective
;
public
function
__construct
(
array
$data
=
null
)
{
$this
->
force_reply
=
true
;
$this
->
selective
=
isset
(
$data
[
'selective'
])
?
$data
[
'selective'
]
:
false
;
}
}
src/Entities/ReplyKeyboardHide.php
0 → 100644
View file @
e44202be
<?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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ReplyKeyboardHide
extends
Entity
{
protected
$hide_keyboard
;
protected
$selective
;
public
function
__construct
(
array
$data
=
null
)
{
$this
->
hide_keyboard
=
true
;
$this
->
selective
=
isset
(
$data
[
'selective'
])
?
$data
[
'selective'
]
:
false
;
}
}
src/Entities/ReplyKeyboardMarkup.php
0 → 100644
View file @
e44202be
<?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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ReplyKeyboardMarkup
extends
Entity
{
protected
$keyboard
;
protected
$resize_keyboard
;
protected
$one_time_keyboard
;
protected
$selective
;
public
function
__construct
(
$data
=
array
())
{
if
(
isset
(
$data
[
'keyboard'
]))
{
if
(
is_array
(
$data
[
'keyboard'
]))
{
foreach
(
$data
[
'keyboard'
]
as
$item
)
{
if
(
!
is_array
(
$item
))
{
throw
new
TelegramException
(
'Keyboard subfield is not an array!'
);
}
}
$this
->
keyboard
=
$data
[
'keyboard'
];
}
else
{
throw
new
TelegramException
(
'Keyboard field is not an array!'
);
}
}
else
{
throw
new
TelegramException
(
'Keyboard field is empty!'
);
}
$this
->
resize_keyboard
=
isset
(
$data
[
'resize_keyboard'
])
?
$data
[
'resize_keyboard'
]
:
false
;
$this
->
one_time_keyboard
=
isset
(
$data
[
'one_time_keyboard'
])
?
$data
[
'one_time_keyboard'
]
:
false
;
$this
->
selective
=
isset
(
$data
[
'selective'
])
?
$data
[
'selective'
]
:
false
;
}
}
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