Provides secured REST API for sending messages to Telegram. Uses MQTT under the hood.
/start
to the bot/sub weather
http -a 1234567:aaBBccDDee https://mqtt2telegram.projects.royz.cc/api/v1.0/send topic=weather payload='<your message>'
or one of the snippets of code below.
import requests
url = "https://mqtt2telegram.projects.royz.cc/api/v1.0/send"
login = "1234567"
password = "aaBBccEEdd"
topic = "YOUR_TOPIC"
json = {
"topic": topic,
"payload": "YOUR_MESSAGE"
}
requests.post(url, auth=(login, password), json=json)
LOGIN=1234567 \
PASSWORD=aaBBccEEdd \
TOPIC=topic \
MESSAGE="hello world" \
curl -v -X POST -u "${LOGIN}:${PASSWORD}" \
https://mqtt2telegram.projects.royz.cc/api/v1.0/send \
-H "Content-Type: application/json" \
-d "{\"topic\": \"${TOPIC}\", \"payload\": \"${MESSAGE}\"}"
import got from "got"
async function sendMessage(login, password, topic, message) {
const url = 'https://mqtt2telegram.projects.royz.cc/api/v1.0/send'
const hash = btoa(`${login}:${password}`)
const options = {
headers: {
authorization: `Basic ${hash}`
}
}
const json = {
topic,
payload: message
}
return got.post(url, {...options, json})
}
async function main() {
const login = '1234567'
const password = 'aaBBccEEdd'
const topic = 'topic'
const message = 'Hello from JavaScript'
const res = await sendMessage(login, password, topic, message)
console.log(res)
}
main().catch(console.log)
/sub
, /list
, /unsub