Download the PHP package intrd/telegram-simple_phpbot without Composer
On this page you can find all versions of the php package intrd/telegram-simple_phpbot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package telegram-simple_phpbot
Telegram Simple PHP Bot - A different and simple approach to use Telegram Bot Plataform (No SSL or setWebhook needed)
| Package | intrd/telegram-simple_phpbot |
|---|---|
| Version | 1.1 |
| Tags | telegram, bot, eggdrop, php |
| Project URL | http://github.com/intrd/telegram-simple_phpbot |
| Author | intrd (Danilo Salles) - http://dann.com.br |
| Copyright | (CC-BY-SA-4.0) 2016, intrd |
| License | Creative Commons Attribution-ShareAlike 4.0 |
| Dependencies | • php >=5.3.0 • intrd/php-common >=1.0.x-dev |
Installation
System requiriments & dependencies
Usage
TL;DR: The sample.php file will check every 5s if someone is mentioning the bot @username or talking him in pvt. It process and reply based on his message w/ some custom triggers.
Steps to setup your bot
- Open Telegram, talk w/ the
http://telegram.me/BotFather, setup a new Telegram Bot and take a note of yourBotID:Botkey, something like:234015785:AAEsvIjg0AcWOINXR0Xt-TGLamuz9k8f10Y - Create a copy of configuration file sample
cp config.ini.sample config.ini - Edit
config.iniand set yourbotkey - Search on Telegram for your
@username_botand start a conversation.. - Now run
php sample.php, it shows yourchatID. Setdebug_chatidonconfig.ini. All bot activity will be forwarded to this conversation, for debbugin purpose. - Change the
triggerto yourusername_botor something you want to trigger your bot replies on groups. - To check if someone is talking w/ your bot every 5 seconds use my bash daemon sample
./run.sh &, orwatch -n5 php sample.phpor setup a cronjob - Now put him on a group..
- Test if your bot is replying when you mention his
trigger, ask him aboutday of week, say him some of$bads, customizereply_get()function.
Tips
Manually check (botid/botkey/chatid)
Browse to your bot URL: https://api.telegram.org/bot<botid>:<botkey>/sendmessage?chat_id=<chatid>&text=hello%20world! in my sample https://api.telegram.org/bot234015785:AAEsvIjg0AcWOINXR0Xt-TGLamuz9k8f10Y/sendmessage?chat_id=65628842&text=hello%20world!, if the bot says Hello World! to you, its ok. PS: group chats use negative chatIDs, -<chatid>
If you prefer not to use daemons (SSL Webserver)
With a SSL webserver serving your sample.php, simply setup your hook URL by browsing:
https://api.telegram.org/bot<botid>:<botkey>/setWebhook?url=http://yourwebserver/sample.php
..and Telegram server will load this URL every time the bot receive a msg.
That's all,
Script this 4 your needs and respect the CC license, thanks!