amirxd / wyng-bot
A powerful Library For Wyng Bot
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-10 19:25:53 UTC
README
A powerful PHP library for interacting with the Wyng Bot API .
It provides an elegant, object-oriented interface to build bots quickly and efficiently.
Features
- Simple and intuitive API
- Long polling with automatic update handling
- Support for all major update types (messages, callbacks, inline queries, polls, etc.)
- Rich set of filters (
command,text,contains,regex,chat_type,user, ...) - Chat‑specific handlers with a fluent interface
- Send and receive media, documents, locations, polls, and more
- Proxy support
- File download helper
- Persistent storage for
last_update_id - PSR‑4 autoloading
- Built on cURL with SSL verification toggle
Requirements
- PHP >= 8.0
ext-curlext-json
Installation
Install via Composer:
composer require amirxd/wyng-bot
Quick Start
<?php require __DIR__ . '/vendor/autoload.php'; use Amirxd\Wyng\Bot\Bot; use Amirxd\Wyng\Tools\Filter; $bot = new Bot('YOUR_BOT_TOKEN'); // Respond to /start command $bot->on(Filter::command('start'), function ($update, $bot) { $bot->sendMessage($update->getChatId(), 'Hello! I am a Wyng bot.'); }); // Echo any text message $bot->on(Filter::text(''), function ($update, $bot) { $text = $update->getText(); if ($text) { $bot->sendMessage($update->getChatId(), "You said: $text"); } }); // Start long polling $bot->run();
Handling Specific Chats
You can attach handlers to a specific chat using the Chat class.
use Amirxd\Wyng\Chat\Chat; $chat = new Chat('CHAT_ID'); $chat->onCommand('help', function ($update, $chat) { $chat->sendMessage('This is a help message from the chat handler.'); }); $chat->onText('ping', function ($update, $chat) { $chat->sendMessage('pong'); }); $bot->HandleChat($chat);
The Chat class also provides shortcuts for all Bot methods (e.g., sendPhoto, sendDocument, banMember, etc.) so you can call them directly on the chat object.
Filters
Filters determine which updates trigger a handler.
Available static constructors:
| Filter | Description |
|---|---|
Filter::command('start') |
Matches a command (e.g., /start) |
Filter::text('hello') |
Matches exact text |
Filter::contains('foo') |
Matches if text contains substring |
Filter::startsWith('bar') |
Matches if text starts with substring |
Filter::endsWith('baz') |
Matches if text ends with substring |
Filter::regex('/^\d+$/') |
Matches a regular expression |
Filter::callbackQuery('data') |
Matches a callback query with specific data (or any if omitted) |
Filter::any() |
Matches any update |
Filter::isPrivate() |
Matches private chats |
Filter::isGroup() |
Matches group / supergroup chats |
Filter::fromUser(12345) |
Matches updates from a specific user ID |
Filter::and(...$filters) |
Logical AND |
Filter::or(...$filters) |
Logical OR |
Sending Messages & Media
The Bot class provides a wide range of methods mirroring the Wyng Bot API:
sendMessageforwardMessagecopyMessagesendPhotosendAudiosendDocumentsendVideosendAnimationsendVoicesendVideoNotesendMediaGroupsendLocationsendVenuesendContactsendPollsendDicesendChatActionsendSticker
And many chat management methods:
banChatMember,unbanChatMember,restrictChatMemberpromoteChatMember,setChatAdministratorCustomTitleexportChatInviteLink,createChatInviteLink,editChatInviteLink,revokeChatInviteLinkapproveChatJoinRequest,declineChatJoinRequestsetChatPhoto,deleteChatPhoto,setChatTitle,setChatDescriptionpinChatMessage,unpinChatMessage,unpinAllChatMessagesleaveChat,getChat,getChatAdministrators,getChatMembersCount,getChatMembersetChatStickerSet,deleteChatStickerSetanswerCallbackQueryeditMessageText,editMessageCaption,editMessageMedia,editMessageReplyMarkupdeleteMessage,deleteMessagessetWebhook,deleteWebhook,getWebhookInfogetUpdates,getMe,getFile,getUserProfilePhotossetMyName,getMyName,setMyDescription,getMyDescriptionsetMyShortDescription,getMyShortDescriptionsetMyCommands,deleteMyCommands,getMyCommandssetMyDefaultAdministratorRights,getMyDefaultAdministratorRightsgetUserChatBoosts,getBusinessConnection
Refer to the source code for full parameter lists.
Proxy Support
$bot->setProxy('http://127.0.0.1:8080');
File Download
$bot->downloadFile('FILE_ID', '/path/to/save/file.jpg');
Storage
The library automatically persists the last processed update_id in Wyng_data.json (located in the project root by default).
You can access or modify storage data via the Storage class if needed.
Update Types
The following update classes are available under Amirxd\Wyng\Models\Updates:
MessageUpdateEditedMessageUpdateChannelPostUpdateEditedChannelPostUpdateCallbackQueryUpdateInlineQueryUpdateChosenInlineResultUpdatePollUpdatePollAnswerUpdateMyChatMemberUpdateChatMemberUpdateChatJoinRequestUpdateGenericUpdate(fallback for unknown types)
Each provides convenient getter methods for accessing the update data.
License
This library is released under the MIT License. See LICENSE for details.
Author
Amirxd
Email: amirxd4488@gmail.com
Happy bot building!