HFCNotificator/README.md

113 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

2023-10-10 22:22:09 +03:00
# Home Front Command Notificator
## A bot to send Discord notifications for HFC alerts
### Created by GaMeNu and yrrad8
2024-02-01 13:01:03 +02:00
> [!WARNING]\
2024-01-15 08:42:59 +02:00
> This bot is unofficial! The public instance may experience downtimes, and there may be issue with the code. Please do not rely on it alone!
2023-10-10 22:22:09 +03:00
2024-09-26 18:03:11 +03:00
> [!CAUTION]\
> As of September 2024, the public instance of HFCNotificator is offline, as none of the project maintainers are available to maintain it. Feel free to host your own instance!
2023-11-17 11:51:04 +02:00
## Table of Contents
- [What is this?](#what-is-this)
- [Setup](#setup)
- [Command Documentation](#command-documentation)
- [About Self Hosting](#self-hosting)
- [Important Links](#links)
## What is This?
2023-10-10 22:22:09 +03:00
This is a bot that connects to the HFC's servers and sends real-time notifications about alerts in Israel.
The bot's development began in 2023, at the start of the Simchat Torah (Iron Swords) War, and is developed by GaMeNu and yrrad8.
The bot aims to be relatively fast, reliable, and available for easy hosting and forking.
Feel free to send suggestions and bug reports through our [discord server](https://discord.gg/K3E4a5ekNy), or just fork the bot and add what you want yourself!
2023-11-17 11:51:04 +02:00
## Setup
Invite the bot to a server, and /register a channel, and you're ready to go!
2023-12-05 18:56:11 +02:00
Alternatively, you can /register a Direct Message / Group DM channel to receive alerts directly!
2023-10-11 13:01:37 +03:00
2023-12-05 18:56:11 +02:00
Please do note that the bot instance listed under the [links section](#links) is hosted on a private machine, and may be a bit slow. It is recommended to [host your own instance](#self-hosting), if possible.
## Command documentation
2023-10-23 09:31:24 +03:00
#### /register
Run in a channel to register it to receive alerts
2023-10-23 09:31:24 +03:00
#### /unregister
Run in a registered channel to stop it from receiving alerts
2023-10-23 09:31:24 +03:00
#### /latest \<time\> \<unit\> \[page\]
Get the latest alerts from up to a certain time back.
#### /about
Get some info about the bot itself
#### /info
Get info about the system and client
2023-10-23 09:31:24 +03:00
### Location commands
#### /locations add \<id\>
Register a location to receive alerts from
#### /locations remove \<id\>
Remove a location to receive alerts from
#### /locations clear \<id\>
Clear all registered locations (Get alerts from everywhere)
2023-10-26 08:53:10 +03:00
#### /locations list \[search\] \[page\]
2023-10-23 09:31:24 +03:00
List all valid locations
2023-10-26 08:53:10 +03:00
#### /locations registered \[search\] \[page\]
2023-10-23 09:31:24 +03:00
List all registered locations
2023-10-10 22:22:09 +03:00
## Self-hosting
### Requirements
2023-10-11 13:01:37 +03:00
#### Required PyPI packages (run each with `pip install`)
2023-10-23 23:24:04 +03:00
**Note:** On Windows you will have to write `python -m pip` instead of `pip` at the beginning of pip install commands
2023-10-23 23:22:03 +03:00
2023-10-23 01:12:37 +03:00
**Note:** as of 2023-10-23, discord.py seems to not install properly for Python 3.11 and above.
The fix we've found is to first install the beta version of package `aiohttp` separately (`aiohttp==3.9.0b0`).
2023-10-23 23:11:24 +03:00
2023-11-16 20:30:27 +02:00
Please use the requirements files (`pip install -r`):
2023-10-23 23:20:22 +03:00
Python 3.10 and below:
2023-10-23 23:11:24 +03:00
```
2023-11-16 20:30:27 +02:00
(python -m) pip install -r requirements.txt
2023-10-23 23:20:22 +03:00
```
Python 3.11 and above:
```
2023-12-05 18:56:11 +02:00
(python -m) pip install -r requirements-3_11.txt
2023-10-23 23:11:24 +03:00
```
2023-10-23 23:20:22 +03:00
2023-10-10 22:22:09 +03:00
#### Other requirements
2023-11-17 11:47:10 +02:00
- A discord bot app ([tutorial](https://github.com/discord-apps/bot-tutorial#how-to-create-an-application))
- MySQL Server (Download link: https://dev.mysql.com/downloads/mysql/) (also available on most package repositories)
2023-11-16 20:42:14 +02:00
### Local data:
#### .env file
2023-12-05 18:56:11 +02:00
Save the following to a file named ".env", and replace the angled brackets with the matching data. Do note that it has to be on the same directory as `main.py`.
2023-10-10 22:22:09 +03:00
```env
TOKEN = <Discord bot token>
AUTHOR_ID = <Your Discord user ID>
DB_USERNAME = <MySQL database username>
DB_PASSWORD = <MySQL database password>
```
2023-11-16 20:42:14 +02:00
#### botinfo file
2023-12-05 18:56:11 +02:00
In botinfo.json, change the "maintainer" value (default is "GaMeNu (@gamenu)") to your username, and maybe add contact information. This is in order to allow others to contact you about issues with your specific instance, and will be publicly available through /info.
2023-11-16 20:42:14 +02:00
**Make sure to not write any personal/private information there!**
2023-10-10 22:22:09 +03:00
## Links
[GitHub](https://github.com/GaMeNu/HFCNotificator)
[Official Bot Invite Link](https://discord.com/api/oauth2/authorize?client_id=1160344131067977738&permissions=0&scope=applications.commands%20bot)
[Bot Profile (Use to open a Direct Message with the bot)](https://discord.com/users/1160344131067977738)
[HFC Website](https://www.oref.org.il/)
[Support Server](https://discord.gg/K3E4a5ekNy)
2023-10-10 22:22:09 +03:00