GithubHelp home page GithubHelp logo

jolice / stackexchangebot Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 29 KB

A telegram bot that notifies you about new questions on Stack Exchange projects

License: MIT License

Java 100.00%
stackoverflow stackoverflow-api stackoverflow-questions telegram-bot telegram-bots telegram-bot-api stackexchange stackexchange-api stackoverflow-crawler telegram telegrambot telegrambots stackoverflow-tags stackoverflow-answer stack-overflow stack-overflow-api stack-exchange-api stack-overflow-posts stack-exchange-sites java-telegram-bot-api

stackexchangebot's Introduction

StackExchange Bot

This is a configurable Telegram bot that sends you notifications about new questions asked on StackExchange projects.

Build Status

Technology

This application utilizes Stack Exchange API to query fresh questions (by the creation date).
Without an application token, the API allows up to 300 requests from single IP address.
This bot performs API requests anonymously, so while configuring a bot, keep this limit in mind.

Building

First, cllone the directory:

git clone [email protected]:riguron/StackExchangeBot.git
cd StackExchangeBot

And build a bot with Spring Boot Maven Plugin:

mvn clean package spring-boot:repackage

The executable JAR will be built under the target directory.

Configuration

In order to use bot, you must put application.yml configuration file under the directory with bot's executable JAR. The configuration must look as follows:

sites: stackoverflow,meta
tags: java,spring
ignore: tags,to,ignore
polling:
   delay: 300000

receiver: YOUR_TELEGRAM_ID
delete:
   payload: delete
bot:
  token: BOT_TOKEN

The file structure must look as follows:

├── application.yml
└── bot.jar

Options

sites

Sites that will be queried for the new questions. Unfortunately, Stack Exchange API doesn't allow for specifying multiple sites in one request, so N requests are required to get new questions from N Stack Exchange projects.

Therefore, specifying N sites will result in decreasing the possible polling frequency due to API limits. While 1 site can be queried 300 times per 24 hours, 2 sites may only be queried 150 times each per 24 hours. The more sites you specify, the less is possible polling frequency you may set. It's recommended to specify only one site, then the queries may be performed approximately every 5 minutes.

tags

Tags you want to watch, i.e the filter for the new questions. Unfortunately, specifying multiple tags produces AND filter rather than OR one. Thus, if you specify both java and spring tags, API returns only questions tagged both with spring and java, and not ones tagged with spring, java or both. So the more tags you specify at once, the less results you get. It's recommended to specify only one tag, for example, your programming language.

ignore

You won't receive questions that are tagged with at least one of these tags. You may specify as many tags as you need.

polling.delay

An option for a scheduler that performs API calls for querying new questions (in milliseconds). A recommended value for one site is 300000, i.e 300 seconds (5 minutes). As there are 86400 seconds in a day and the API limit is 300 requests per day, it's allowed to perform requests not more often than every 288 seconds.

Remember that each specified site involves one additional API request, soo the initial polling delay must be increased by two for each new site.

receiver

Your Telegram ID. To find it out, take advantage of @JsonDumpBot. Send any message to it, any it will respond you with a JSON containing the following element:

"from": {
      "id": 42,
      "is_bot": false,
      "first_name": "Your Name",
      "username": "your_nick_name",
      "language_code": "en"
    },

42 is your Telegram ID, the value for the receiver property.

delete.payload

This option accepts any non-null value, you may set it to whatever you want. However, you'd better don't modify it and leave as it is.

bot.token

To use this bot, you must create a Telegram bot that will send you the notifications about new questions. After the creation, copy the bot's token to the configuration.

Note that you must start a dialog with a bot in order to receive notifications. Telegram doesn't allow bots to send messages to the users that don't have an active dialog with a bot!

Troubleshooting

Q: An application doesn't start.

  • Make sure that application.yml resides in the same directory with your executable JAR and that it's configured in a proper way, with accordance to the instructions.
  • Check whether you don't miss some application property.

Q: I don't receive any messages from my bot.

  • Make sure that you've started a dialog with your bot. If you're new to Telegram bots, you may want to read the guide.
  • There might be no new questions or you've specified too strict filters. Try to adjust the tags and ignored tags.
  • Stack Exchange API may be down for the maintenance. The internal server error exception will be fired, the stack trace will be displayed.
  • Check application logs for other kinds of exceptions.

stackexchangebot's People

Contributors

jolice 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.