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
adcc2041
Commit
adcc2041
authored
Jan 05, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Article works:w
parent
d203e113
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
41 deletions
+138
-41
InlinequeryCommand.php
src/Commands/InlinequeryCommand.php
+18
-40
InlineQuery.php
src/Entities/InlineQuery.php
+1
-1
InlineQueryResultArticle.php
src/Entities/InlineQueryResultArticle.php
+119
-0
No files found.
src/Commands/InlinequeryCommand.php
View file @
adcc2041
...
...
@@ -13,6 +13,8 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\Entity
;
class
InlinequeryCommand
extends
Command
{
...
...
@@ -27,49 +29,25 @@ class InlinequeryCommand extends Command
{
$update
=
$this
->
getUpdate
();
$inline_query
=
$update
->
getInlineQuery
();
//$inline_query->getQuery();
//$update->getUpdateId();
$data
=
array
();
$data
[
'inline_query_id'
]
=
$update
->
getUpdateId
();
$data
[
'inline_query_id'
]
=
(
string
)
time
();
//$data['cache_time']=60;
//$data['is_personal']="false";
//$data['next_offset']="122;
$data
[
'results'
]
=
'[
{
"type": "article",
"id": "001",
"title": "UC Browser",
"message_text": "Text of the first message",
"parse_mode": "Markdown",
"disable_web_page_preview": true,
"url": "telegram.com",
"hide_url": true,
"description": "Optional. Short description of the result",
"thumb_url": "http://icons.iconarchive.com/icons/martz90/circle/64/uc-browser-icon.png",
"thumb_width": 64,
"thumb_height": 64
},
{
"type": "article",
"id": "002",
"title": "Bitcoin",
"message_text": "*Text of the second message*",
"parse_mode": "Markdown",
"disable_web_page_preview": true,
"url": "bitcoin.org",
"hide_url": true,
"description": "Short description of the result",
"thumb_url": "http://www.coinwarz.com/content/images/bitcoin-64x64.png",
"thumb_width": 64,
"thumb_height": 64
}
]'
;
$query
=
$inline_query
->
getQuery
();
$result
=
Request
::
answerInlineQuery
(
$data
);
$data
=
[];
$data
[
'inline_query_id'
]
=
$inline_query
->
getId
();
$articles
=
[];
$articles
[]
=
[
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
];
$articles
[]
=
[
'id'
=>
'002'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
];
$articles
[]
=
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
];
$array_article
=
[];
foreach
(
$articles
as
$article
)
{
$array_article
[]
=
new
InlineQueryResultArticle
(
$article
);
}
$array_json
=
'['
.
implode
(
','
,
$array_article
)
.
']'
;
$data
[
'results'
]
=
$array_json
;
$result
=
Request
::
answerInlineQuery
(
$data
);
return
$result
->
isOk
();
//return 1;
}
}
src/Entities/InlineQuery.php
View file @
adcc2041
...
...
@@ -43,7 +43,7 @@ class InlineQuery extends Entity
return
$this
->
id
;
}
public
function
geFrom
()
public
function
ge
t
From
()
{
return
$this
->
from
;
}
...
...
src/Entities/InlineQueryResultArticle.php
0 → 100644
View file @
adcc2041
<?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\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultArticle
extends
Entity
{
protected
$type
;
protected
$id
;
protected
$title
;
protected
$message_text
;
protected
$parse_mode
;
protected
$disable_web_page_preview
;
protected
$url
;
protected
$hide_url
;
protected
$description
;
protected
$thumb_url
;
protected
$thumb_width
;
protected
$thumb_height
;
public
function
__construct
(
array
$data
)
{
$this
->
type
=
'article'
;
$this
->
id
=
isset
(
$data
[
'id'
])
?
$data
[
'id'
]
:
null
;
if
(
empty
(
$this
->
id
))
{
throw
new
TelegramException
(
'id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
if
(
empty
(
$this
->
title
))
{
throw
new
TelegramException
(
'title is empty!'
);
}
$this
->
message_text
=
isset
(
$data
[
'message_text'
])
?
$data
[
'message_text'
]
:
null
;
if
(
empty
(
$this
->
message_text
))
{
throw
new
TelegramException
(
'message_text is empty!'
);
}
$this
->
parse_mode
=
isset
(
$data
[
'parse_mode'
])
?
$data
[
'parse_mode'
]
:
null
;
$this
->
disable_web_page_preview
=
isset
(
$data
[
'disable_webpage_preview'
])
?
$data
[
'disable_webpage_preview'
]
:
null
;
$this
->
url
=
isset
(
$data
[
'url'
])
?
$data
[
'url'
]
:
null
;
$this
->
hide_url
=
isset
(
$data
[
'hide_url'
])
?
$data
[
'hide_url'
]
:
null
;
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
thumb_url
=
isset
(
$data
[
'thumb_url'
])
?
$data
[
'thumb_url'
]
:
null
;
$this
->
thumb_width
=
isset
(
$data
[
'thumb_width'
])
?
$data
[
'thumb_width'
]
:
null
;
$this
->
thumb_height
=
isset
(
$data
[
'thumb_height'
])
?
$data
[
'thumb_height'
]
:
null
;
}
public
function
getType
()
{
return
$this
->
type
;
}
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getMessageText
()
{
return
$this
->
message_text
;
}
public
function
getParseMode
()
{
return
$this
->
parse_mode
;
}
public
function
getDisableWebPagePreview
()
{
return
$this
->
disable_web_page_preview
;
}
public
function
getUrl
()
{
return
$this
->
url
;
}
public
function
getHideUrl
()
{
return
$this
->
hide_url
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getThumbUrl
()
{
return
$this
->
thumb_url
;
}
public
function
getThumbWidth
()
{
return
$this
->
thumb_width
;
}
public
function
getThumbHeight
()
{
return
$this
->
thumb_height
;
}
}
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