Skip to content

kkiwior/Telegram.Bot.CovidPoll

Repository files navigation

Project status

Build Unit Tests Integration Tests
Build Status Build Status Build Status

What it is for?

I wanted to create a useful system to predict covid cases for the next day. It's not something like ML, but it depends on users’ votes.

How it works

You must add this bot to your group. Then, once a day the bot will send polls with options based on the last number of new covid cases. Users have time to vote, when the time ends the polls will be closed and prediction number based on votes from all groups, will be send to them. On the next day, the bot will check if there is new data in API (until it effects). When there is new data, the bot will send the information about new covid cases and the information who voted properly.

Some details

  • It's important to know that, all group members have their own vote ratio, even when one member is in many groups, he has separated ratio in each of groups.
  • Vote ratio is for covid cases prediction, covid predictions are calculated by weighted average.
  • Users have an opportunity to vote outside the numbers in poll. They have for that command /vote {here_covid_cases}.

Installation

The latest version of this bot is always in DockerHub (connected by Azure Pipelines to this repository):

docker pull kwiatek1100/telegram.bot.covidpoll:latest

Usage

It is very simple to start working with bot on your own hosting.

Prepare database and place for logging

This project is using MongoDb and datalust/seq for logging.

  1. Create bot token (for BotSettings__Token).
  2. Check your AdminUserId in https://api.telegram.org/bot{your_key}/getUpdates. You need to send at least one message to the bot and check your userId from this message here.
  3. Run Seq, then create an API key (for Seq__ApiKey and Seq__ServerUrl).
  4. Run MongoDb and fill this connection string with your data (for MongoSettings__ConnectionString).
mongodb://username:password@ip_with_port
  1. The bot is integrated with this API (for CovidTrackingSettings__Url). But you can write your own implementation for another API. :)
  2. Run Telegram.Bot.CovidPoll replacing values with yours.
docker run -ti -d \
-e BotSettings__Token="telegram_bot_token" \
-e BotSettings__AdminUserId="telegram_admin_user_id" \
-e MongoSettings__ConnectionString="mongo_connection_string" \
-e MongoSettings__DbName="db_name" \
-e CovidTrackingSettings__Url="covid_api_url" \
-e Seq__ApiKey="seq_api_key" \
-e Seq__ServerUrl="seq_url" \
kwiatek1100/telegram.bot.covidpoll
  1. Of course, you can also change when the polls are starting and closing or when the bot is starting to fetch data.
-e BotSettings__PollsStartHour=""
-e BotSettings__PollsEndHour=""
-e CovidTrackingSettings__FetchDataHour=""

License

  • Project is under MIT license

  • Dependencies can have own licenses:

https://www.nuget.org/packages/FluentAssertions/
https://www.nuget.org/packages/Microsoft.NET.Test.SDK
https://www.nuget.org/packages/Moq/
https://www.nuget.org/packages/xunit/
https://www.nuget.org/packages/xunit.runner.visualstudio
https://www.nuget.org/packages/Microsoft.VisualStudio.Azure.Containers.Tools.Targets/
https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/
https://www.nuget.org/packages/Microsoft.Extensions.Hosting
https://www.nuget.org/packages/Microsoft.Extensions.Http/
https://www.nuget.org/packages/mongodb.driver
https://www.nuget.org/packages/Seq.Extensions.Logging/
https://www.nuget.org/packages/Telegram.Bot/

About

Bot for new covid cases prediction.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published