Creating a Telegram Bot to Show information about your mixnodes.


Have you ever thought about seeing your node'status without having to open your browser, directly from your cellphone via telegram? This is possible and I will teach you how.
Requirements
Basic Knowledge of Python
Python3.8 or newer
After downloading and installing all the requirements, create a Python script.
#import the modules PyTelegramBotAPI, Selenium and BeatifulSoup
import time
import telebot
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options
#These options will allow you to run
# the application without any GUI
options = Options()
options.add_argument('--headless=new')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox-')
options.add_argument('--disable-dev-shm-usage')
#Load the chrome driver
driver = webdriver.Chrome(options=options)
# Replace TOKEN with your own token obtained from FatherBot
bot = telebot.TeleBot(TOKEN)
# These functions will search for elements in a file html
def getTitle(bs):
rs = bs.findAll('p', {'class':'chakra-text css-1jijfcn'})
return (rs[0].get_text())
def getRoutingScore(bs):
rs = bs.findAll('p', {'class':'chakra-text css-2ar9as'})
return (rs[0].get_text())
def getHourScore(bs):
rs = bs.findAll('p', {'class':'chakra-text css-1fe1nli'})
return (rs[0].get_text())
# This function will format the html and get the results
def getBS(html):
driver.get(html)
time.sleep(0.3)
html = driver.page_source
bs = BeautifulSoup(html, 'html.parser')
info = []
key = ['title', 'hourscore', 'routingscore']
info.append(getTitle(bs))
info.append(getHourScore(bs))
info.append(getRoutingScore(bs))
ret = dict(zip(key, info))
return (ret)
# This function will wait for the /nodes command,
# and will return with your node information
# you can replace nodes with any other command you want
@bot.message_handler(commands=['nodes'])
def send_info(message):
temp = getBS("insert the url of your node here")
text = temp.get("title") + "\n" +
temp.get("routingscore") + " " +
temp.get("hourscore") + "\n"
bot.reply_to(message, f"{text}")
# This command keeps the bot running
bot.infinity_polling()
Now run the command on your Telegram and see the result, it will look something like this:
Your bot is ready, I hope you liked it, and feel free to implement new features.
Read more about the bot that TupiNymQuim is developing at: https://github.com/TupiNymQuim/IncognitoBot/
Join the Nym Community
Discord // Telegram // Element // Twitter
Privacy loves company
English // 中文 // Русский // Türkçe // Tiếng Việt // 日本 // Française // Español // Português // 한국인
#NYM #Freedom #Privacy #Security
Subscribe to my newsletter
Read articles from Vitor Santanna directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vitor Santanna
Vitor Santanna
I'm João Vitor Sant'Anna, Currently I'm an Associate Degree IT at FAETEC/RJ and a software engineer student at 42Rio. I'm very interested in the areas of Cybersecurity and DevOps.