Page MenuHomePhabricator

[alias-server] Telegram bot to announce new alias registrations
ClosedPublic

Authored by bytesofman on Mar 3 2023, 19:42.

Details

Summary

T2969

Depends on D13232

Add a Telegram bot to broadcast msgs to a Telegram channel when new aliases are registered.

Test Plan
cp secrets.js.sample sample.js

Enter your bot information and channel ID (can ping me to use mine or create your own using the Botfather)
node index.js
Create some aliases with Cashtab running locally with aliases enabled
Confirm msgs broadcast

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested changes to this revision.Mar 4 2023, 00:05
emack added a subscriber: emack.

Upon initialization of the bot, the alias server throws a MongoBulkWriteException before the bot reporting on a number of recent registrations but then rate limits itself after 5 hits. Is this expect behavior or should it only be report on new registrations from the point of bot startup?

image.png (400×1 px, 62 KB)

image.png (685×656 px, 175 KB)

image.png (98×699 px, 19 KB)

After waiting out the rate limit, I registered fisherman2 which was picked up by the alias server's websocket but the bot did not announce it in the tg chat.

image.png (112×919 px, 25 KB)

This revision now requires changes to proceed.Mar 4 2023, 00:05

I waited for the next block (781805) to be found and the alias server rate limited itself again, whilst the bot simply repeated the previous batch of registrations but no sign of fisherman2

image.png (838×452 px, 110 KB)

Upon initialization of the bot, the alias server throws a MongoBulkWriteException before the bot reporting on a number of recent registrations but then rate limits itself after 5 hits. Is this expect behavior or should it only be report on new registrations from the point of bot startup?

I saw this behavior from the last diff due to conflicts between aliases existing in the database and the new "reserved aliases" feature. The database needs to be wiped before node index.js. This diff is built on top of the reserved alias diff, so it has the same thing.

After waiting out the rate limit, I registered fisherman2 which was picked up by the alias server's websocket but the bot did not announce it in the tg chat.

The screenshot here shows an "added to the mempool" websocket msg. Currently the app only responds to new blocks found -- and will only send a msg if an alias tx was confirmed in that block

I waited for the next block (781805) to be found and the alias server rate limited itself again, whilst the bot simply repeated the previous batch of registrations but no sign of fisherman2

This is related to the first issue of the database needing to be erased to get rid of registrations that conflict with the new reserved list. Expected behavior for now (will probably not have a need to patch) is for Telegram to get rate limited if it's asked to send more than 25 messages. So, when you run the app for the first time on an empty database, and it writes 170-odd entries, Telegram will probably only send 25 msgs. We could patch this by batching Tg msgs and using timeouts, but it would get complicated and probably only be relevant for this initial start-up scenario.

This revision is now accepted and ready to land.Mar 5 2023, 03:02