Skip to content

TheFamilyTeam/Nestar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Nestar

python telegram

Python Framework for Telegram's Bot API

Dependence

Install it this way:

pip install requests

Usage

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.

About

Python Framework for Telegram's Bot API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages