499602D2 / tg-launchbot

LaunchBot πŸš€ – Rocket launch information and notifications bot for Telegram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LaunchBot – a rocket launch information and notifications bot for Telegram πŸš€

LaunchBot keeps you up to date with what's going up, around the clock, since 2019. Over a million launch notifications delivered to thousands of chats and groups!

Reachable as @rocketrybot on Telegram.

preview

Features

LaunchBot uses the LaunchLibrary2 API to fetch launch information on scheduled intervals. The bot provides multiple forms of information: launch notifications, information about upcoming flights, and a simple flight schedule displaying upcoming flights at a glance.

Other features include...

  • user-configurable notifications on a per-provider and per-country basis
  • user-configurable notification times from 4 different options
  • notifications of launches being postponed
  • muteable launches
  • direct links to launch webcasts
  • automatically cleared notification messages
  • simple information refresh with Telegram's message buttons
  • spam management for groups (removes requests the bot won't respond to)

Basic instructions

LaunchBot has not been tested on Windows. However, it should run on any Linux distribution, alongside with macOS. Other Unix-like OSs are untested, but should work as long as they have a recent version of Go installed. LaunchBot has been tested on 32-bit ARM, so all Raspberry Pis should work.

  1. Clone the repository and install all dependencies with go get all

  2. Move into the main directory with cd cmd

  3. Build the program with ./build.sh. This may require you to allow executing the script: this can be done with chmod +x build.sh

  4. Move back into the main folder with cd ..

Now, you can run the program: to start, open a new terminal window, and run ./launchbot. The bot will ask you for a Telegram bot API key: you can get one from BotFather on Telegram.

If you would like to view the logs as they come in, instead of saving them to a dedicated log-file, add the --debug CLI flag: ./launchbot --debug.

Data

SQLite: data/launchbot.db: houses all data the bot needs to operate, including launch information, statistics, chat preferences, etc.

JSON: data/config.json: used to configure the bot by setting the Telegram bot API key, alongside with some other configuration information.

Logs: data/launchbot-logs.log, when the --debug CLI flag has not been provided.

You can specify your personal account's Telegram user ID in config.json in the form owner: 12345. This disables the logging of commands sent by you.

Privacy

In order to operate, LaunchBot must save a chat ID. This may or may not be your user ID, depending on whether the chat is a one-on-one or a group chat. The chat ID is used to deliver notifications, manage spam, and keep statistics. Users can optionally store their time zone as a time zone database entry (e.g. Europe/Berlin), which can be removed at any time.

When LaunchBot is added to a new group, it looks up the number of users the group has. Apart from the chat ID, this is the only extra information saved, and is only used to get an idea of the reach of the bot.

The above only applies on a per-bot-instance basis. The creator of the bot chooses whether to configure the bot to be able to read all text messages, not just ones directed at the bot. Telegram bots are, by nature, extremely privacy invasive: don't add unknown bots to group chats, unless it's hosted by you or someone you trust.

Dependencies

Expand dependency list
  • gopkg.in/telebot.v3: a fantastic Telegram bot API wrapper.

  • github.com/bwmarrin/discordgo: Discord API wrapper, currently unused.

  • github.com/rs/zerolog: a fantastic logging library.

  • bradfitz/latlong: used to determine time zone from a Telegram location message.

  • dustin/go-humanize: used to produce various human-friendly strings, such as time- and unit-related ones.

  • go-co-op/gocron: used to schedule regular function calls, for e.g. dumping statistics to the disk.

  • go-resty/resty/v2: a great alternative to the standard http library, with exponential back-off baked in.

  • hako/durafmt: pretty ETA strings.

  • jayco/go-emoji-flag: emoji flags from country codes.

  • jdkato/prose/v2: natural language parsing for LL2's launch descriptions.

  • procyon-projects/chrono: used to schedule API calls and notifications to a specific point in time.

  • gorm: a fantastic ORM library for Go, used with the main SQLite database.

Roadmap and historical changelog

View changelog/roadmap
## 1.0 / first implementation (November 2019)

- βœ… implemented uncached API requests

- βœ… implemented the request of next launch via a direct API call


## 1.2 / basic features (December 2019)

- βœ… implement /next using DB calls

- βœ… implement support for SpaceX core information


## 1.3 / user-facing features (January 2020)

- βœ… add "next" and "previous" button(s) to /next command

- βœ… add a mute button to notifications

- βœ… update /notify to be more user friendly

- βœ… implement /feedback

- βœ… improve notification handling with the hold flag -> moving NETs and info text regarding them

- βœ… change launch database index from tminus to net


## 1.4 / basic improvements (February 2020 ->)

- βœ… Notify users of a launch being postponed if a notification has already been sent

- βœ… disable logging of text messages; how to do feedback? (log feedback messages in a global array?)

- βœ… add tbd-field to launches, so schedule can only show certain launch dates (filter certain and uncertain with a button)

- βœ… add location (i.e. state/country) below pad information (Florida, USA etc.)


## 1.5 / user-facing features

- βœ… delete older notification messages when a new one is sent

- ❌ add a "more info"/"less info" button to /next and notification messages

- βœ… add probability of launch and launch location, separate from mission name etc. with \n\n

- βœ… allow users to set their own notifications (i.e. 24h/12h/...)

- βœ… allow users to set their own timezone


## 2.0 / major back-end changes (October 2020)

- βœ… upgrade to the LL2 API (LL1 closes at the end of October)

- βœ… update from telepot Telegram API wrapper to python-telegram-bot

- βœ… perform API requests intelligently, as the monthly request quota is enough for only one request every 8 minutes

	- βœ… don't update API on startup, unless it has been sufficiently long since last check: store requests in memory + storage
	
	- βœ… use schedule to schedule requests: just before a launch is due, plus for when notifications are supposed to be sent
	
	- βœ… a raw update schedule of once every 15 - 60 minutes
	
- βœ… check for launch notifications intelligently
	
	- βœ… on API update, check for updated launch times (notification send times) -> clear schedule queue -> schedule next checks for when a notification is supposed to be sent
	
- βœ… store LL2 and SpX API data in the same database

- βœ… combine all separate database files into one file with multiple tables

- βœ… attempt to split the monolithic file into multiple separate files, starting with the API request functions

- βœ… index launches by the new unique launch ID instead of launch name

- βœ… fully integrate new API and notifications systems with LaunchBot 1.5

- βœ… complete pre_handler(), so we can update time zone information and get feedback

- βœ… re-add statistics to all needed places

- βœ… open-source LaunchBot ✨


## 2.1 / Telegram API updates (December 2020 to February 2022)

- βœ… Postpone notification fixes

- βœ… Local bot API server support

- βœ… Attempt to reduce rate-limits caused by sending stuff too fast at Telegram's API

- βœ… Various edge-case and bug fixes


## 3.0 / LaunchBot rework in Go (May 2022)

- βœ… Improved code quality and project layout

- βœ… Improved robustness and error recoverability of the backend

- βœ… Dequeue messages properly to stay within API limits

- βœ… Smart spam management for commands and callbacks, which reduces rate-limiting

- βœ… Remove excessive complexity in storage and caching

- βœ… Modularize most functions so that adding e.g. Discord functionality is easier

- βœ… Reuse proven Python logic where possible with direct translation

- βœ… Improve performance with better caching and Go's performance upside

- βœ… Dance around API limits by sending incomplete messages, where the rest of the message can be later expanded

- βœ… Add some group-specific settings, e.g. command permissions

## 3.1 / threaded sender (June 2022 ->)

- βœ… Implements a threaded sender, achieving much higher send-rates

- βœ… A massive amount of edge-case bug fixes

- βœ… General improvements

## 3.2 and onwards

- [ ] Inline queries (should be trivial to do)

- [ ] Handle window starts/ends

	- Instead of continuous postponements, notify of window start -> 5 min notification

- [ ] Support for general event types (event/upcoming endpoint)

	- Wrap launches in an Event{} type

- [ ] "Featured launches" subscription option, for interesting one-off launches

- [ ] Weekly summary messages

- [ ] Web-app based set-up screen, notification info?

	- https://core.telegram.org/bots/webapps

	- Privacy implications

- [ ] Discord support

About

LaunchBot πŸš€ – Rocket launch information and notifications bot for Telegram

License:MIT License


Languages

Language:Go 99.9%Language:Shell 0.1%