Telegram <-> node.js app (with mongodb) <-> xmpp.wordpress.com
When you tell the bot to follow a blog, it using our jabber server that users can use as well, and subscribes to blog posts by messaging bot@im.wordpress.com with sub awesome.wordpress.com .
Now, when a post is being posted to the blog, jabber will notify our blog about the new post, the blog will then figure out if it's being followed in a telegram group/channel and message that group/channel with the new post.
You'll need a mongodb instance to develop locally, you can get one easily via docker:
docker run -d -p 27017:27017 -p 28017:28017 -e MONGODB_USER="telegram" -e MONGODB_DATABASE="telegram" -e MONGODB_PASS="qEpRcsp{3vkHYdpjJdT9}aLTp.P8zE" --name telegramdb tutum/mongodb
docker exec -it telegramdb /bin/bash
mongo telegram -u telegram -p qEpRcsp{3vkHYdpjJdT9}aLTp.P8zE
This account will be subscribing to XMPP notifications for new posts - see WordPress.com jabber.
No special permissions are required by this account - it will just be subscribing to publicly available WordPress.com and jetpack sites.
Users will add this bot as an admin to their channel/group and then follow WordPress.com blogs.
This also needs no special initial permissions - users will need to add this bot to their channel/group to allow it to post.
You configure bot commands by sending a message to BotFather:
/setcommands
BotFather will respond with 'Choose a bot to change the list of commands.' so choose your bot
BotFather will respond with 'OK. Send me a list of commands for your bot ...' so respond with the following message:
follow - Follow a new site
unfollow - Stop following a site
following - List currently followed sites
reset - Stop following all sites
Create a local .env
file in the root of this project:
# telegram bot token
BOT_TOKEN=
# jabber credentials
XMPP_USER=
XMPP_PASS=
# mongo configuration
MONGODB_URI=mongodb://127.0.0.1:27017/wp-telegram-bot
Alternatively, you may define each of these environment variables in your shell.
npm install
npm start
DEBUG=wp-telegram* npm start