Monday, 22 November 2021

Post message on telegram bot

 go to telegram app on your phone, or log in with telegram web

and then search for bot father.

create a new bot /newbot

now follow along with instructions.

type a name for your bot

I had a hard time finding a username ( username must be botname_bot)

now you'll get a token to authenticate with your bot.

keep the access token securely. Anyone with access token can manipulate your bot

alright, now we have the access token. The next question is how to send messages with the bot.

we will create a group with our bot. And then our bot will massage to that group

it's simple as that

now let's create a new group in telegram and add the bot to that group.

search with the username of your bot . 

add our bot to the group. after adding give admin permission to our bot, to give access to the bot to send messages to the group (not all the permissions are necessary but I will give because this is a demo group and nothing harmful will happen ).

now everything is set in this end.

The next thing we need is to get our group chat id to send messages to the group.

https://api.telegram.org/botBOT_API_KEy:BOT_ACCESS_TOCKEN/sendMessage?chat_id=@YOUR_BOT_NAME&text=YOUR_MESSAGE  

run this code in browser.


OR

USe curl php code 

<!------Code Start --->

$ch = curl_init();

        curl_setopt($ch,CURLOPT_URL,"https://api.telegram.org/botBOT_API_KEY:BOT_ACCESS_TOCKEN/sendMessage");

        curl_setopt($ch, CURLOPT_POST,1);

        curl_setopt($ch,CURLOPT_POSTFIELDS,"chat_id=@YOUR_BOT_NAME&text=Binance,$pair,BUY=$ask,Target=$r1");

        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json'));

//curl_setopt($ch,CURLOPT_HTTPHEADER,$header);

$result=curl_exec($ch);

curl_close($ch);

$result=json_decode($result);

echo"<pre>";

print_r($result);

<!---- code end ---->

Monday, 1 November 2021

How TO - Copy Textarea to Clipboard without jquery

 How TO - Copy Textarea to Clipboard without jquery


<script>

function copy() {

  let textarea = document.getElementById("textarea");

  textarea.select();

  document.execCommand("copy");

}

</script>

<textarea rows=40 cols=100% id=textarea>Dedicated Servers

Get all the raw performance of the server for your resource-intensive websites & applications


Choose from SSD or HDD plans High-memory servers New Generation Processors Get started within minutes

Starts at Rs.8,666.60 /mo

more details visit https://sakhihosting.in/dedicated-servers.php</textarea>

<br>

<button onclick="copy()">Copy</button>


Example :

How TO - Copy Text to Clipboard

how to copy text to the clipboard with JavaScript.

Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>

.tooltip {

  position: relative;

  display: inline-block;

}


.tooltip .tooltiptext {

  visibility: hidden;

  width: 140px;

  background-color: #555;

  color: #fff;

  text-align: center;

  border-radius: 6px;

  padding: 5px;

  position: absolute;

  z-index: 1;

  bottom: 150%;

  left: 50%;

  margin-left: -75px;

  opacity: 0;

  transition: opacity 0.3s;

}


.tooltip .tooltiptext::after {

  content: "";

  position: absolute;

  top: 100%;

  left: 50%;

  margin-left: -5px;

  border-width: 5px;

  border-style: solid;

  border-color: #555 transparent transparent transparent;

}


.tooltip:hover .tooltiptext {

  visibility: visible;

  opacity: 1;

}

</style>

</head>

<body>


<p>Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.</p>


<input type="text" value="Hello World" id="myInput">


<div class="tooltip">

<button onclick="myFunction()" onmouseout="outFunc()">

  <span class="tooltiptext" id="myTooltip">Copy to clipboard</span>

  Copy text

  </button>

</div>


<script>

function myFunction() {

  var copyText = document.getElementById("myInput");

  copyText.select();

  copyText.setSelectionRange(0, 99999);

  navigator.clipboard.writeText(copyText.value);

  

  var tooltip = document.getElementById("myTooltip");

  tooltip.innerHTML = "Copied: " + copyText.value;

}


function outFunc() {

  var tooltip = document.getElementById("myTooltip");

  tooltip.innerHTML = "Copy to clipboard";

}

</script>

</body>

</html>