Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Creating attack warning by Telegram by Bidu

PiecePaperCode edited this page Feb 15, 2020 · 1 revision

1 - Access your telegram and add the contact “@BotFather” he is responsible for creating Telegram bots

2 - Start a conversation with “@BotFather”

Type: /newbot Type: <Name of Bot> Type: <username do bot> (ATTENTION this username must end with the string “Bot”)

3 - The "@BotFather" will answer you with the "token" this token will be used to send the conversations, save, because, we will use it. In the same message there is a t.me/ link, click this link to start a conversation with the bot you just created, you need to send any message to register that you accept to receive messages from the bot.

4 - Add the contact “@get_id_bot” in the telegram. He is responsible for telling you your user id in the telegram, also known as chat_id.

5 - Start a conversation with “@get_id_bot” Type: @get_id_bot Your Chat ID will be returned, save this value we will use in the code.

6 - Start Coding

import requests
class Telegram:
	def __init__(self):
 		self.TOKEN = <<Token Telegram>>
 		self.CHAT = << CHAT ID >>
 		self.URL = "https://api.telegram.org/bot{}".format(self.TOKEN)
 	def get_url(self, url):
 		response = requests.get(url)
 		content = response.content.decode("utf8")
 		return content
 	def send_message(self, text):
 		url = self.URL + "/sendMessage?text={}&chat_id={}".format(text, self.CHAT)
 		self.get_url(url)
#test
#Telegram().send_message('test')
Clone this wiki locally