PushItBot

A bot to help you integrate your website and scripts with Telegram

View On GitHub


Project maintained by fopina Hosted on GitHub Pages — Theme by mattgraham

PushItBot allows you to easily get notifications from your website or scripts on your Telegram window.

Just talk to @PushItBot on Telegram to check it out.

API Docs


Getting Started

To start, please open your Telegram app and start a chat with @PushItBot to generate your API token.
You can also start the chat by clicking here.

Once you have the token, keep it away from others, it is just for you.

In this page, whenever you see <YOUR_TOKEN>, you should replace with the token you obtained here.

Pushing Messages

In order to push notifications to your Telegram account, you need to send HTTP requests to the following address:

https://tgbots.skmobi.com/pushit/<YOUR_TOKEN>
Field Type Description
msg string Required The message text you want to send
format string Optional Formatting options as supported by Telegram Bot API. Possible values: (empty string), Markdown, HTML

API Usage Examples


Remember to replace the sample token 105e48ff92b92263f3397ed55f275a81 with your own!

Any browser

Just load the URL (using GET)

https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81?msg=testing+1+2+3

cURL

curl -d 'msg=*testing* _1_ `2` 3' \
     -d "format=Markdown" \
     https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81

JavaScript

With jQuery

$.ajax("https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81", {
    type:"POST",
    data: {"msg": "*testing* _1_ `2` 3", "format": "Markdown"},
    dataType: 'json',
    success:function(data, textStatus, jqXHR) {
      if (data.ok) {
        alert("Message sent!");
      }
      else {
        alert("Failed (" + data.code + "): " + data.description);
      }
    },
    error: function(jqXHR, textStatus, errorThrown) {alert("API Failure");}
});

Python

With urllib2

import urllib
import urllib2
import json

r = urllib2.urlopen(
  'https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81',
  data=urllib.urlencode({
    'msg': '<b>testing</b> <i>1</i> <code>2</code> 3',
    'format': 'HTML'
  })
)
print json.loads(r.read())

With requests

import requests

r = requests.post(
  'https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81',
  data={
    'msg': '<b>testing</b> <i>1</i> <code>2</code> 3',
    'format': 'HTML'
  }
)
print r.json()

Go

package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
)

func main() {
	resp, err := http.PostForm(
		"https://tgbots.skmobi.com/pushit/355aac1b7f0efe055b3f0f663cae16fc",
		url.Values{
			"msg":    {"hello"},
			"format": {"Markdown"},
		},
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

PHP

With cURL

<?php
$params = array(
	'msg' => "testing 1 2 3"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$result = curl_exec($ch);
curl_close($ch);

print_r($result);
?>

With file_get_contents()

<?php
$params = array(
	'msg' => "testing 1 2 3"
);
$post = http_build_query($params);

$context = stream_context_create(array(
                'http' => array(
                    'method' => 'POST',
                    'header' => "Content-type: application/x-www-form-urlencoded\r\n",
                    'content' => $post,
                    'timeout' => 10,
                ),
            ));

$response = file_get_contents("https://tgbots.skmobi.com/pushit/105e48ff92b92263f3397ed55f275a81", false, $context);
print $response
?>

Source - Host your own


Check out the project in Github.
README has instructions on how to quickly set up your own copy of @PushItBot in OpenShift!