Coder Social home page Coder Social logo

pbkhrv / handshake-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 382 KB

Telegram bot that answers queries and sends alerts about the Handshake (HNS) blockchain

License: MIT License

Dockerfile 0.24% JavaScript 99.76%
handshake telegram-bot

handshake-telegram-bot's Introduction

Handshake (HNS) Telegram bot

This is a Telegram bot that can answer queries about the Handshake blockchain and deliver alerts related to Handshake name auctions.

Handshake is an experimental peer-to-peer root naming system that allows you to register and manage top-level domain names on a blockchain, and transact in its native cryptocurrency.

You can talk to the public instance of this bot called "Handshake Bot" @handshakehns_bot on Telegram, or you can run your own and talk to it.

It's a proof of concept

It does what it says on the tin, BUT the code is not very good - it was thrown together rather quickly. You've been warned.

How to run it

Requirements

  • hsd: the bot needs to connect to a Handshake node to access the blockchain. hsd doesn't have to be running on the same computer, but the bot needs to be able to connect the hsd http RPC port.
  • Node.js and npm: make sure you have Node.js version 14 or higher installed.
  • Telegram bot API key that you can get by talking to Telegram's BotFather

Install dependencies

Fork the repo, install dependencies and verify

npm install 
npm run test

Configure the bot

Currently, the bot can only be configured by setting environment variables (command line options are on the todo list).

You must set the following environment variables before running it:

  • TELEGRAM_BOT_API_KEY: this is the API key that you get from Telegram's BotFather when you create your bot
  • SQLITE_FILE_PATH: path to the SQLite database file. If you don't want to persist any of the data and store everything in memory only, use :memory:.

Optional environment variables:

  • HSD_NETWORK: name of the Handshake network to use. Default is main
  • HSD_HOST: host name or IP address that bot uses to connect to the hsd http RPC endpoint. Default is localhost
  • HSD_PORT: port number of hsd http RPC endpoint. Default value depends on the selected Handshake network, most likely 12037.

Run it

node src/app.js

handshake-telegram-bot's People

Contributors

pbkhrv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rithvikvibhu

handshake-telegram-bot's Issues

Ability to set "bidding ends soon" and "reveal ends soon" alerts on particular name

Desired behavior:

Set an alert

> somename

< name: somename
<
< This name is in auction...
< Bidding will end in about 82 hours (494 blocks left)
< [ Create alert for this name ]
< [ Alert me before bidding ends ]

> ...user clicks on [ Alert me before bidding ends ]

< How many blocks before the end of the bidding period would you like to be notified?

> 10

< Alert created for 10 blocks before bidding ends on the name 'somename'
< [ Cancel alert ]

Show alert details

> somename

< name: somename
<
< This name is in auction...
< Bidding will end in about 82 hours (494 blocks left)
< ---
< You have an alert set for the name somename
<
< - Alert for 10 blocks before bidding ends
<
< Upcoming block height milestones:
< - in 484 blocks (~3 days): Bidding ends in 10 blocks
< [ Cancel alert ]

Fuzzy search thru names in /alerts

If i say /alerts *easy*, bot should show details of all my alerts for names that contain the word easy in them.

Why: I have lots of alerts set, this would make it easier for me to see alert details for a particular name without having to type it out fully.

Alert on fuzzy matching names with simple syntax

I should be able to set alerts for names that match a pattern, and receive notifications whenever bot detects name actions on names that match that pattern.
Use * wildcard anywhere in the name to make arbitrary patterns.
No support for punycode (?)

Pattern *hand* should match any name that contains the word hand in it.

if bot skips block, alerts can get out of sync

Every time significant name actions happen for names that we have alerts set for, bot recalculates block height "milestones" for those alerts. If bot skips blocks (because it's down or hsd is down etc), it doesn't process gaps in blocks, which means it can miss important name actions and not recalculate block heights.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.