Giter Site home page Giter Site logo

telegramwrapper's Introduction

PHP Telegram Wrapper

Latest Version Total Downloads

PHP wrapper for Telegram bots

Install

This project uses Composer. To use the project, just add it to your dependencies.

$ composer require hetisniels/telegram-wrapper

Without Composer

It is possible you dont like Composer or you just want to get the source and use it. In this case download the latest release in releases page. Note: You need to make your own autoloader for this to work!

Sample usage

Telegram\Bot

<?php
class HelloWorldCommand implements \Telegram\Commands\ICommand
{
	public function call($name, $arguments, $caller)
	{
		$keyboard = $caller->getBot()->createKeyboard(); // Alternative: $keyboard = new KeyboardBuilder();
		$keyboard = $keyboard->button('A')->button('B')->row()->button('C')->button('D')->row()->setResizable(true)->setOneTime(true)->keyboard();
		
		$caller->reply('Hello World!', false, $keyboard);
	}
	
	public function getDescription()
	{
		return 'Sends the popular "Hello World" text.';
	}
	
	public function getUsage()
	{
		return '<command>';
	}
}

$bot = new Telegram\Bot('API_TOKEN');
$bot->addCommand('helloworld', new HelloWorldCommand());
$bot->work();

And now, just send the message "/helloworld" to the bot!

Telegram\Api

<?php
$bot = new Telegram\Api('API_TOKEN');

$bot->getUpdates(); // Returns array of Update

An custom command handler is needed when using the API. The API provides only the methods & types from Telegram.

telegramwrapper's People

Contributors

nielsvanvelzen avatar

Watchers

Мурад Джелилов avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.