All Projects → yusufusta → Boting

yusufusta / Boting

Licence: MIT license
Simple but powerful Telegram Bot library

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Boting

tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (+509.52%)
Mutual labels:  telegram-bot-api, telegrambot
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (+238.1%)
Mutual labels:  telegram-bot-api, telegrambot
tinjecttelegram delphi
LMCODE
Stars: ✭ 37 (+76.19%)
Mutual labels:  telegram-bot-api, telegrambot
tcp server client
A thin and simple C++ TCP client server
Stars: ✭ 124 (+490.48%)
Mutual labels:  multithreading
teleflask
A python telegram bot framework based on flask and pytgbot
Stars: ✭ 43 (+104.76%)
Mutual labels:  telegram-bot-api
aiogram dialog
GUI framework on top of aiogram
Stars: ✭ 263 (+1152.38%)
Mutual labels:  telegram-bot-api
sphere-mt
C/C++ Multithreading Programming Course Materials.
Stars: ✭ 17 (-19.05%)
Mutual labels:  multithreading
github client
Open source bot telegram menggunakan bahasa code dart
Stars: ✭ 24 (+14.29%)
Mutual labels:  telegram-bot-api
node-tdlib
TDLib Binding with Telegram Bot API Reimplemention for Node.js
Stars: ✭ 35 (+66.67%)
Mutual labels:  telegram-bot-api
bsuir-csn-cmsn-helper
Repository containing ready-made laboratory works in the specialty of computing machines, systems and networks
Stars: ✭ 43 (+104.76%)
Mutual labels:  multithreading
AyaRay
A Modern C++ Windows-platform physically based renderer developing by Chang Yu.
Stars: ✭ 29 (+38.1%)
Mutual labels:  multithreading
Chatroom-in-C
A simple Chatroom built in C programming language. The program is built uses multithreading for handling multiple clients.
Stars: ✭ 51 (+142.86%)
Mutual labels:  multithreading
Image-Scraper
Fast concurrent image scraper
Stars: ✭ 35 (+66.67%)
Mutual labels:  multithreading
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (+61.9%)
Mutual labels:  telegram-bot-api
llb
Dead simple event-driven load-balancer
Stars: ✭ 27 (+28.57%)
Mutual labels:  multithreading
code-delphi-async
Code examples from Delphi Event-based and Asynchronous Programming Book
Stars: ✭ 32 (+52.38%)
Mutual labels:  multithreading
TeleTweet
🦉 A telegram Twitter bot that will allow you send tweets!
Stars: ✭ 34 (+61.9%)
Mutual labels:  telegrambot
telega
Telegram Bot API implementation
Stars: ✭ 21 (+0%)
Mutual labels:  telegram-bot-api
portable-threads
Portable threads API for Common Lisp (from GBBopen project)
Stars: ✭ 13 (-38.1%)
Mutual labels:  multithreading
banana
🍌 Modern C++ Telegram Bot API library
Stars: ✭ 30 (+42.86%)
Mutual labels:  telegram-bot-api

Boting

Simple yet Powerful.

🇹🇷 Türkçe | 🇬🇧 English

Boting, The best Telegram Bot library for fast and asynchronous bot with PHP.

Features

  • %100 Async (😳)
  • Always compatible with the latest BotAPI
  • Single file, small size, simple to upload.
  • File download/upload
  • Events
  • WebHook & GetUpdates support

Requirements

If you can install Guzzle, you can use it easily.

Install

If you have Composer, you can install it very easily:

composer require quiec/boting

If you want to use the beta version:

composer require quiec/boting:dev-master

If Composer is not installed, you can easily install it Here.

Get Update

You can get Update with two ways;

Webhook

If you are going to receive Updates with Webhook method, just add "true" to the handler.

...
$Bot->Handler("Token", true);

Get Updates

This method is used by default. You don't need to add anything extra.

...
$Bot->Handler("Token");

Events

With the new feature added to Boting 2.0, you can now add convenience commands and capture message types with on.

$bot->command

The command, must be regex.

Example (Let's catch /start command):

$Bot->command("/\/start/m", function ($Update, $Match) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"]; 
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]);
});

Let's add another command handler:

$Bot->command("/[!.\/]start/m", function ($Update, $Match) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"]; 
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]);
});

The bot will now also respond to /start,!Start,.start commands.

$bot->on

The bot will execute the function if a message of the specified type arrives.

No match is used, On.

Example (If the photo comes):

$Bot->on("photo", function ($Update) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"]; 
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Photo came"]);
});

You can look at the On Types here.

$bot->answer

You can use the answer function to answer inline_query or callback_query.

Example (Let's answer inline):

$Bot->answer("inline_query", function ($Update) use ($Bot) {
    $Bir = ["type" => "article", "id" => 0, "title" => "test", "input_message_content" => ["message_text" => "This bot created by Boting..."]];
    $Bot->answerInlineQuery(["inline_query_id" => $Update["inline_query"]["id"], "results" => json_encode([$Bir])]);    
});

Special Events

If you do not want to use ready-made functions, you can define your own function.

❗️Type true if you are going to use Webhook or false if you will get it with GetUpdates.

$Main = function ($Update) {...};
$Bot->Handler("Token", false, $Main);

Example (A function that responds to the /start message):

<?php
require __DIR__ . '/vendor/autoload.php'; //We include the base of the bot.
use Boting\Boting; // We say we want to use the base.

$Bot = new Boting(); // We start the base.
$Main = function ($Update) use ($Bot) { // We create a function called Main.
    if (!empty($Update["message"])) { // We check if a message has arrived.
        $Mesaj = $Update["message"]["text"]; // We throw the message into the variable.
        $ChatId = $Update["message"]["chat"]["id"]; // We get the chat id to send messages.

        if ($Mesaj === "/start") { // We check if the message is start.
            $Bot->sendMessage(["chat_id" => $ChatId, "text" => "You started the bot."]); // We use the sendMessage function.
        }
    }
};
$Bot->Handler("Here ur bot token", false, $Main); // We define our bot token and function.

Commands

Commands are the same as BotAPI commands. You can use BotAPI commands in the same way.

Let's give an example you wanted to send a message,We look at the required parameters from BotAPI.

We need chat_id and text. So let's write our code.

$Bot->sendMessage(["chat_id" => "@fusuf", "text" => "Hello!"]);

The process is complete. Commands return Array, after operation.

Examples

We can show this file as a very good example of using the library. Also a code that responds to a simple /start message:

<?php
require __DIR__ . '/vendor/autoload.php'; //We include the base of the bot.
use Boting\Boting; // We say we want to use the base.

$Bot = new Boting(); // We start the base.
$Bot->command("/[!.\/]start/m", function ($Update, $Match) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"]; 
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]);
});
$Bot->Handler("Here ur bot token"); // We define our bot token.

Licence

This project is completely open source and protected under MIT license. Please refer to the LICENSE.md file

Contact

You can contact me on Telegram or open Issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].