Should work with both tg-cli and bot api, but tg-cli needs to run on json port
Another rewrite, I hope to finish this one.