Skip to content

Instantly share code, notes, and snippets.

@DatDraggy
Last active May 8, 2022 10:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DatDraggy/b07e30f547cd5c292cf7e5bae2af58df to your computer and use it in GitHub Desktop.
Save DatDraggy/b07e30f547cd5c292cf7e5bae2af58df to your computer and use it in GitHub Desktop.
Telegram Flexpool Hashrate in Name
from pyrogram import Client, idle
import flexpoolapi
from apscheduler.schedulers.background import BackgroundScheduler
#### AREA TO EDIT
address = "0x...."
app = Client(
"my_account",
api_id=12345,
api_hash="0123456789abcdef0123456789abcdef"
)
#### AREA TO EDIT
units = ['H/s', 'KH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s']
def putHashrate():
me = app.get_chat("me")
miner = flexpoolapi.miner("eth", address)
effective = miner.stats().current_effective_hashrate
unit = 0
while effective > 1000:
unit += 1
effective = round(effective / 1000, 4)
hashrate = str(round(effective, 1)) + ' ' + units[unit]
if not me.last_name:
last_name = ""
else:
last_name = me.last_name
if last_name[-3:] != "H/s":
last_name = last_name + " " + hashrate
else:
name = last_name.split(" ")
name.pop()
name.pop()
last_name = ' '.join(name) + ' ' + hashrate
app.update_profile(last_name=last_name)
scheduler = BackgroundScheduler()
scheduler.add_job(putHashrate, "interval", minutes=5)
scheduler.start()
app.start()
putHashrate()
idle()
app.stop()
@DatDraggy
Copy link
Author

DatDraggy commented Mar 14, 2022

Instructions

You will need to create a custom telegram app to get your access details like api_id and hash.
Read the docs on how to create one here https://docs.pyrogram.org/start/setup

Install Python (at least 3.6)
Then run
pip3 install -U pyrogram tgcrypto flexpoolapi-v2 apscheduler
to install the packages needed.

Edit main.py and enter your address and api id/hash

Run the file with python3 main.py. Running it the first time you will need to login to your account.

Protipp: You can run the script on your rig in HiveOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment