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
9966f3ec
Unverified
Commit
9966f3ec
authored
Aug 26, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix example commands.
parent
ae619a1b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
75 deletions
+82
-75
ForcereplyCommand.php
examples/Commands/ForcereplyCommand.php
+6
-5
ImageCommand.php
examples/Commands/ImageCommand.php
+20
-12
InlinekeyboardCommand.php
examples/Commands/InlinekeyboardCommand.php
+6
-6
KeyboardCommand.php
examples/Commands/KeyboardCommand.php
+41
-44
MarkdownCommand.php
examples/Commands/MarkdownCommand.php
+9
-8
No files found.
examples/Commands/ForcereplyCommand.php
View file @
9966f3ec
...
@@ -25,7 +25,7 @@ class ForceReplyCommand extends UserCommand
...
@@ -25,7 +25,7 @@ class ForceReplyCommand extends UserCommand
protected
$name
=
'forcereply'
;
protected
$name
=
'forcereply'
;
protected
$description
=
'Force reply with reply markup'
;
protected
$description
=
'Force reply with reply markup'
;
protected
$usage
=
'/forcereply'
;
protected
$usage
=
'/forcereply'
;
protected
$version
=
'0.0.
5
'
;
protected
$version
=
'0.0.
6
'
;
/**#@-*/
/**#@-*/
/**
/**
...
@@ -36,10 +36,11 @@ class ForceReplyCommand extends UserCommand
...
@@ -36,10 +36,11 @@ class ForceReplyCommand extends UserCommand
$message
=
$this
->
getMessage
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$data
=
[];
$data
=
[
$data
[
'chat_id'
]
=
$chat_id
;
'chat_id'
=>
$chat_id
,
$data
[
'text'
]
=
'Write something:'
;
'text'
=>
'Write something:'
,
$data
[
'reply_markup'
]
=
new
ForceReply
([
'selective'
=>
false
]);
'reply_markup'
=>
new
ForceReply
([
'selective'
=>
false
]),
];
return
Request
::
sendMessage
(
$data
);
return
Request
::
sendMessage
(
$data
);
}
}
...
...
examples/Commands/ImageCommand.php
View file @
9966f3ec
...
@@ -25,7 +25,7 @@ class ImageCommand extends UserCommand
...
@@ -25,7 +25,7 @@ class ImageCommand extends UserCommand
protected
$name
=
'image'
;
protected
$name
=
'image'
;
protected
$description
=
'Send Image'
;
protected
$description
=
'Send Image'
;
protected
$usage
=
'/image'
;
protected
$usage
=
'/image'
;
protected
$version
=
'1.0.
0
'
;
protected
$version
=
'1.0.
1
'
;
/**#@-*/
/**#@-*/
/**
/**
...
@@ -37,18 +37,26 @@ class ImageCommand extends UserCommand
...
@@ -37,18 +37,26 @@ class ImageCommand extends UserCommand
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$text
=
$message
->
getText
(
true
);
$data
=
[];
$data
=
[
$data
[
'chat_id'
]
=
$chat_id
;
'chat_id'
=>
$chat_id
,
$data
[
'caption'
]
=
$text
;
'caption'
=>
$text
,
];
//
return Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
//
Return a random picture from the telegram->getUploadPath().
return
Request
::
sendPhoto
(
$data
,
$this
->
ShowRandomImage
(
$this
->
telegram
->
getUploadPath
()));
return
Request
::
sendPhoto
(
$data
,
$this
->
ShowRandomImage
(
$this
->
telegram
->
getUploadPath
()));
}
}
//return random picture from the telegram->getUploadPath();
private
function
ShowRandomImage
(
$dir
)
{
/**
* Return the path to a random image in the passed directory.
*
* @param string $dir
*
* @return string
*/
private
function
ShowRandomImage
(
$dir
)
{
$image_list
=
scandir
(
$dir
);
$image_list
=
scandir
(
$dir
);
return
$dir
.
"/"
.
$image_list
[
mt_rand
(
2
,
count
(
$image_list
)
-
1
)];
}
return
$dir
.
'/'
.
$image_list
[
mt_rand
(
2
,
count
(
$image_list
)
-
1
)];
}
}
}
examples/Commands/InlinekeyboardCommand.php
View file @
9966f3ec
...
@@ -26,7 +26,7 @@ class InlinekeyboardCommand extends UserCommand
...
@@ -26,7 +26,7 @@ class InlinekeyboardCommand extends UserCommand
protected
$name
=
'Inlinekeyboard'
;
protected
$name
=
'Inlinekeyboard'
;
protected
$description
=
'Show inline keyboard'
;
protected
$description
=
'Show inline keyboard'
;
protected
$usage
=
'/inlinekeyboard'
;
protected
$usage
=
'/inlinekeyboard'
;
protected
$version
=
'0.0.
1
'
;
protected
$version
=
'0.0.
2
'
;
/**#@-*/
/**#@-*/
/**
/**
...
...
examples/Commands/KeyboardCommand.php
View file @
9966f3ec
...
@@ -23,9 +23,9 @@ class KeyboardCommand extends UserCommand
...
@@ -23,9 +23,9 @@ class KeyboardCommand extends UserCommand
* {@inheritdoc}
* {@inheritdoc}
*/
*/
protected
$name
=
'keyboard'
;
protected
$name
=
'keyboard'
;
protected
$description
=
'Show a custom keybord with reply markup'
;
protected
$description
=
'Show a custom keybo
a
rd with reply markup'
;
protected
$usage
=
'/keyboard'
;
protected
$usage
=
'/keyboard'
;
protected
$version
=
'0.
0.6
'
;
protected
$version
=
'0.
1.0
'
;
/**#@-*/
/**#@-*/
/**
/**
...
@@ -35,70 +35,67 @@ class KeyboardCommand extends UserCommand
...
@@ -35,70 +35,67 @@ class KeyboardCommand extends UserCommand
{
{
$message
=
$this
->
getMessage
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
[];
$data
=
[
$data
[
'chat_id'
]
=
$chat_id
;
'chat_id'
=>
$chat_id
,
$data
[
'text'
]
=
'Press a Button:'
;
'text'
=>
'Press a Button:'
,
];
//Keyboard examples
//Keyboard examples
$keyboards
=
[];
$keyboards
=
[];
//0
//
Example
0
$keyboard
[]
=
[
'7'
,
'8'
,
'9'
];
$keyboard
=
[
];
$keyboard
[]
=
[
'4'
,
'5'
,
'6
'
];
$keyboard
[]
=
[
'7'
,
'8'
,
'9
'
];
$keyboard
[]
=
[
'1'
,
'2'
,
'3
'
];
$keyboard
[]
=
[
'4'
,
'5'
,
'6
'
];
$keyboard
[]
=
[
' '
,
'0'
,
'
'
];
$keyboard
[]
=
[
'1'
,
'2'
,
'3
'
];
$keyboard
[]
=
[
' '
,
'0'
,
' '
];
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//1
$keyboard
[]
=
[
'7'
,
'8'
,
'9'
,
'+'
];
$keyboard
[]
=
[
'4'
,
'5'
,
'6'
,
'-'
];
$keyboard
[]
=
[
'1'
,
'2'
,
'3'
,
'*'
];
$keyboard
[]
=
[
' '
,
'0'
,
' '
,
'/'
];
//Example 1
$keyboard
=
[];
$keyboard
[]
=
[
'7'
,
'8'
,
'9'
,
'+'
];
$keyboard
[]
=
[
'4'
,
'5'
,
'6'
,
'-'
];
$keyboard
[]
=
[
'1'
,
'2'
,
'3'
,
'*'
];
$keyboard
[]
=
[
' '
,
'0'
,
' '
,
'/'
];
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//2
//Example 2
$keyboard
=
[];
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'B'
];
$keyboard
[]
=
[
'B'
];
$keyboard
[]
=
[
'C'
];
$keyboard
[]
=
[
'C'
];
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//3
//Example 3
$keyboard
=
[];
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'B'
];
$keyboard
[]
=
[
'B'
];
$keyboard
[]
=
[
'C'
,
'D'
];
$keyboard
[]
=
[
'C'
,
'D'
];
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//4 (bots 2.0)
//Example 4 (bots version 2.0)
$keyboard
=
[];
$keyboard
[]
=
[
$keyboard
[]
=
[
[
[
'text'
=>
'request_
contact'
,
'text'
=>
'Send my
contact'
,
'request_contact'
=>
true
'request_contact'
=>
true
,
],
],
[
[
'text'
=>
'request_
location'
,
'text'
=>
'Send my
location'
,
'request_location'
=>
true
'request_location'
=>
true
,
]
]
,
];
];
$keyboards
[]
=
$keyboard
;
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//Return a random keyboard.
$keyboard
=
$keyboards
[
mt_rand
(
0
,
count
(
$keyboards
)
-
1
)];
$data
[
'reply_markup'
]
=
new
ReplyKeyboardMarkup
(
$data
[
'reply_markup'
]
=
new
ReplyKeyboardMarkup
(
[
[
'keyboard'
=>
$keyboards
[
1
]
,
'keyboard'
=>
$keyboard
,
'resize_keyboard'
=>
true
,
'resize_keyboard'
=>
true
,
'one_time_keyboard'
=>
false
,
'one_time_keyboard'
=>
false
,
'selective'
=>
false
'selective'
=>
false
,
]
]
);
);
...
...
examples/Commands/MarkdownCommand.php
View file @
9966f3ec
...
@@ -25,7 +25,7 @@ class MarkdownCommand extends UserCommand
...
@@ -25,7 +25,7 @@ class MarkdownCommand extends UserCommand
protected
$name
=
'markdown'
;
protected
$name
=
'markdown'
;
protected
$description
=
'Print Markdown tesxt'
;
protected
$description
=
'Print Markdown tesxt'
;
protected
$usage
=
'/markdown'
;
protected
$usage
=
'/markdown'
;
protected
$version
=
'1.0.
0
'
;
protected
$version
=
'1.0.
1
'
;
/**#@-*/
/**#@-*/
/**
/**
...
@@ -35,17 +35,18 @@ class MarkdownCommand extends UserCommand
...
@@ -35,17 +35,18 @@ class MarkdownCommand extends UserCommand
{
{
$message
=
$this
->
getMessage
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
[];
$data
=
[
$data
[
'chat_id'
]
=
$chat_id
;
'chat_id'
=>
$chat_id
,
$data
[
'parse_mode'
]
=
'MARKDOWN'
;
'parse_mode'
=>
'MARKDOWN'
,
$data
[
'text'
]
=
"*bold* _italic_ `inline fixed width code` ```preformatted code block
'text'
=>
'*bold* _italic_ `inline fixed width code`
```
preformatted code block
code block
code block
```
```
[Best Telegram bot api!!](https://github.com/akalongman/php-telegram-bot)
[Best Telegram bot api!!](https://github.com/akalongman/php-telegram-bot)
'
,
"
;
]
;
return
Request
::
sendMessage
(
$data
);
return
Request
::
sendMessage
(
$data
);
}
}
...
...
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