Coder Social home page Coder Social logo

wp-telegram-bot's Introduction

How it works

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 [email protected] 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

Getting started with development

create a WordPress.com account

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.

create a telegram bot

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.

configure bot commands

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

local configuration

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.

start server

npm install
npm start

debugging

DEBUG=wp-telegram* npm start

wp-telegram-bot's People

Contributors

tug avatar markryall avatar yurynix avatar

Watchers

 avatar

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.