Python Framework for Telegram's Bot API
Install it this way:
pip install requests
Bot Sample
import nestar
def handle(bot, update):
print(update)
bot = nestar.Nestar("YOUR:TOKEN")
bot.loop(handle)
Plugin Sample
class NestarPlugin:
def handle(self, bot, update):
bot.sendMessage(chat_id=update["message"]["from"]["id"], text="Hi! Welcome to Nestar, {}".format(update["message"]["from"]["first_name"]))
PHP Handler Sample
import nestar
bot = nestar.Nestar("YOUR:TOKEN")
bot.loop(php_handler="nestar.php")
<?php
$update = json_decode($argv[1], true);
function apiRequest($method, $params){
echo("nestarAnswer".json_encode(["method" => $method, "params" => $params]));
}
if($update["message"]["text"] == "/start"){
apiRequest("sendMessage", ["chat_id" => $update["message"]["chat"]["id"], "text" => "hello"]);
}
Notes
You won't need an handler if there is at least one plugin in the plugins folder.