problem using javascript and sending hashtag

Copper Contributor

I have a big problem I even don't know where to begin because my code is in Java and I need to use HTML tags too. So the data I'm using is mostly numbers within tables in the webpage and I want to use a specific tag in my code via a result of a row that meets a column (like Excel). I also have another problem:

I'm trying to 'post' the # sign to make some words turn to hashtags in the target url but the code doesn't work and it's via API using this code:

 

true == function()
{
var getMyItem = function (str)
{
if (sessionStorage.getItem(str) == null)
{
setMyItem(str, 0);
return 0;
}
return sessionStorage.getItem(str);
}
var setMyItem = function (key, value)
{
sessionStorage.setItem(key, value);
}

function bot(post)
{
const Http = new XMLHttpRequest();
var Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Token
var ID= "xxxxxx";
var url= 'https://bot.xxx/api/'+Token+'/sendMessage?text='+post+'&chat_id='+ID;
Http.open("GET", url);
Http.send();
}
// you need to change the url variable contents for your own Telegram API or those of the same SN APIs..

 

 

So when it comes to call the post like with this code:

 

var myDate = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
var post_n = "%23Hi. It's: " + myDate + "\n";
var post = encodeURI(post_n);

if (getMyItem(key + "htr") != "yes")
{
bot(post);
setMyItem((key + "htr"),"yes");
}


return true;
}
}()

 

, it doesn't support # sign in my browsers including Chrome an Firefox and nothing is sent actually. So if it were for Telegram, the bot would look like this (and I donno if it works or not but I'm talking about another SN): var url= 'https://api.telegram.org/'+Token+'...

Please tell me how to send # code. By the way, "%23" doesn't work.

0 Replies