var token = "I removed my BOT token from here for the purpose of posting it in the public domain",
offset = 1,
chatid = "" //chat id of the bot chat
var msg = {"chat_id":chatid, "text":"MY MESSAGE I WANT TO SEND"}
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.CreateText( "Hello" );
txt.SetTextSize( 32 );
lay.AddChild( txt );
app.AddLayout( lay );
newHttpRequest("post","sendMessage",msg)
}
function newHttpRequest(type,func,asset)
{
var httpRequest=new XMLHttpRequest();
httpRequest.onreadystatechange=function()
{
if(httpRequest.readyState==4)
{
with(httpRequest)
{
alert(httpRequest.response)
handle(JSON.parse(httpRequest.response).result)
}
}
};
httpRequest.open(type,addr+func,true);
httpRequest.send(JSON.stringify(asset));
}
function handle(msgs)
{
alert(JSON.stringify(msgs))
if(msgs) msgs.forEach( function(msg)
{
if(msg.update_id>offset) offset=msg.update_id
})
}