Skip to content

Commit

Permalink
update doc, and add chennel post, update chennel post
Browse files Browse the repository at this point in the history
  • Loading branch information
JamshidbekAkhlidinov committed Apr 20, 2024
1 parent b9e8305 commit 971bfa8
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor/
composer.lock
13 changes: 13 additions & 0 deletions BotApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public function forwardMessages($chat_id, $from_chat_id, $message_ids, $options
}


public function deleteMessage($chat_id, $message_id)
{
$fields = ['chat_id' => $chat_id, 'message_id' => $message_id];
return $this->request('deleteMessage', $fields);
}

public function deleteMessages($chat_id, $message_ids)
{
$fields = ['chat_id' => $chat_id, 'message_id' => $message_ids];
return $this->request('deleteMessages', $fields);
}


public function getMe()
{
return $this->request('getMe');
Expand Down
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,108 @@ if ($text == '/button') {

```

<img src="docphoto/buttons.png" alt="buttons">

**CallBack buttonlar bilan ishlash**

```php
$botApi = new BotApi("$token");
$update = new Update($botApi->getWebhookUpdate());

if ($update->isCallbackQuery()) {
$callback = $update->getCallbackQuery();
$user = $callback->getUser();
$user_id = $user->getId();
$data = $callback->getData();

$keyboard = new Keyboard();
$keyboard->addCallbackDataButton("Button title", "data_name");

if ($data == 'data_name') {
$botApi->sendMessage(
$user_id,
"<b>Your text</b>",
[
'reply_markup' => $keyboard->init(),
'parse_mode' => 'html',
]
);
}
}
```

**Inline Query bilan ishlash**

Bu yerda turli xildagi respons lar yaratish va ularning attribute lari yozib qo'yilgan

https://core.telegram.org/bots/api#inlinequeryresult

```php
$botApi = new BotApi("$token");
$update = new Update($botApi->getWebhookUpdate());

if ($update->isInlineQuery()) {
$inlineQuery = $update->getInlineQuery();
$query = $inlineQuery->getQuery();
$query_id = $inlineQuery->getId();

$keyboard = new Keyboard();
$keyboard->addCallbackDataButton("Your CallBack button", "data_name");

$photoUrl = "https://storage.kun.uz/source/thumbnails/_medium/10/egAyZ4_AtLF8OGa4bxD4hpZTI6vHFaqj_medium.jpg";

if($query == 'photo'){
$response = new InlineQueryResult();
$response->addPhoto(
"$photoUrl",
"Rasmni yuborish",
[
'description' => 'bu rasm chatga yuboriladi',
'caption' => $query,
]
);
$botApi->answerInlineQuery(
$query_id,
$response->init(),
);
}

if($query == 'text'){
$response = new InlineQueryResult();
$response->addText(
"Xabarni yuborish",
"$query",
[
'description' => 'bu xabar chtga yuboriladi'
]
);
$botApi->answerInlineQuery(
$query_id,
$response->init(),
);
}

if($query == 'document'){
$response = new InlineQueryResult();
$response->addDocument(
"$photoUrl",
"Yuborish doc",
'application/pdf',
[
'caption' => $query
]
);
$botApi->answerInlineQuery(
$query_id,
$response->init(),
);
}


}
```
**Mana shu xolatdagi query lardan foydalnish mumkun**

<img src="docphoto/inline.png" alt="rasm">

# telegram
3 changes: 3 additions & 0 deletions Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
namespace ustadev\telegram;

use ustadev\telegram\traits\CallbackQuery;
use ustadev\telegram\traits\ChannelPost;
use ustadev\telegram\traits\EditedChannelPost;
use ustadev\telegram\traits\InlineQuery;
use ustadev\telegram\traits\Message;

class Update extends Objects
{
use Message, CallbackQuery, InlineQuery;
use ChannelPost, EditedChannelPost;
}
Binary file added docphoto/buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion types/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ustadev\telegram\traits\File;
use ustadev\telegram\traits\Location;
use ustadev\telegram\traits\MessageEntity;
use ustadev\telegram\traits\Photo;
use ustadev\telegram\traits\Poll;
use ustadev\telegram\traits\PollAnswer;
use ustadev\telegram\traits\PollOption;
Expand All @@ -32,7 +33,7 @@
class Message extends Objects
{
use Audio, Chat, Contact, Dice, Document, File, Location;
use MessageEntity, Poll, PollAnswer, PollOption, Story;
use MessageEntity, Poll, Photo, PollAnswer, PollOption, Story;
use Text, User, Venue, Video, VideoNote, Voice, WebAppData;

public function getMessageId()
Expand Down

0 comments on commit 971bfa8

Please sign in to comment.