1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00
modufur/README.md

132 lines
3.8 KiB
Markdown
Raw Normal View History

2018-02-13 04:28:26 +00:00
# Modufur
2022-02-22 19:28:12 +00:00
An experimental [Hikari](https://www.hikari-py.dev) Discord bot for reverse image searching using [SauceNAO](https://saucenao.com) & [Kheina](https://kheina.com)
2022-02-23 01:46:01 +00:00
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B1AUB66)
2022-02-22 23:35:24 +00:00
## Prerequisites
2023-03-07 03:49:03 +00:00
Linux is used for the following commands\
2022-02-22 23:35:24 +00:00
[WSL](https://docs.microsoft.com/en-us/windows/wsl) can be used to run Linux on Windows, but is not required to run the bot
2022-02-21 07:10:57 +00:00
## Requirements
2022-02-22 19:02:47 +00:00
[Git](https://git-scm.com/downloads)\
2022-02-21 07:10:57 +00:00
[Python](https://www.python.org) 3.10+\
2022-02-24 19:40:56 +00:00
[Poetry](https://python-poetry.org/docs/master)
2022-02-21 10:51:13 +00:00
## Installing
2023-03-07 03:49:03 +00:00
1. Clone repository
2022-02-21 07:10:57 +00:00
```
2023-03-17 06:15:14 +00:00
git clone https://github.com/Myned/modufur.git
2022-02-21 07:10:57 +00:00
```
2023-03-07 03:49:03 +00:00
2. Go to project folder
2022-02-21 07:10:57 +00:00
```
2023-03-17 06:15:14 +00:00
cd modufur
2022-02-21 07:10:57 +00:00
```
2023-03-07 03:49:03 +00:00
3. Create a virtual environment and install dependencies
2022-02-21 07:10:57 +00:00
```
2022-02-22 19:02:47 +00:00
poetry install
2022-02-21 07:10:57 +00:00
```
## Usage
2023-03-07 03:49:03 +00:00
1. Go to project folder
2022-02-22 19:02:47 +00:00
```
2023-03-17 06:15:14 +00:00
cd modufur
2022-02-22 19:02:47 +00:00
```
2023-03-07 03:49:03 +00:00
2. Run with optimizations
2022-02-21 07:10:57 +00:00
```
2022-02-22 23:46:06 +00:00
poetry run python -OO run.py
2022-02-21 07:10:57 +00:00
```
2022-02-21 10:51:13 +00:00
## Setup
2022-02-22 19:02:47 +00:00
Run to create `config.toml`\
The file will automatically generate if it does not exist
2022-02-21 07:10:57 +00:00
```
guilds = [] # guild IDs to register commands, empty for global
master = 0 # guild ID to register owner commands
2022-02-21 07:10:57 +00:00
client = 0 # bot application ID
token = "" # bot token
activity = "" # bot status
saucenao = "" # saucenao token
e621 = "" # e621 token
```
2023-03-07 03:49:03 +00:00
### systemd service
Run in the background on most Linux machines\
2023-03-17 06:15:14 +00:00
This assumes that the project folder is located at `~/.git/modufur`\
2023-03-07 03:49:03 +00:00
Change the `WorkingDirectory` path in `modufur.service` if this is not the case
1. Go to project folder
2022-02-21 10:51:13 +00:00
```
2023-03-17 06:15:14 +00:00
cd modufur
2022-02-21 10:51:13 +00:00
```
2023-03-07 03:49:03 +00:00
2. Copy user service file
2022-02-21 10:51:13 +00:00
```
2023-03-07 03:49:03 +00:00
cp modufur.service ~/.config/systemd/user
```
3. Replace `user` in `WorkingDirectory` with current user
```
sed -i "s|\(WorkingDirectory=/home/\)user|\1$(whoami)|" ~/.config/systemd/user/modufur.service
```
4. Reload user daemon
2023-03-07 03:49:03 +00:00
```
systemctl --user daemon-reload
```
5. Start and enable service on login
2022-02-21 10:51:13 +00:00
```
2023-03-07 03:49:03 +00:00
systemctl --user enable --now modufur
2022-02-21 10:51:13 +00:00
```
6. Enable lingering to start user services on boot
2023-03-07 03:49:03 +00:00
```
sudo loginctl enable-linger username
```
## Updating
1. Go to project folder
```
2023-03-17 06:15:14 +00:00
cd modufur
2022-02-21 10:51:13 +00:00
```
2023-03-07 03:49:03 +00:00
2. Pull changes from repository
```
git pull
```
3. Update virtual environment
2022-02-21 10:51:13 +00:00
```
poetry update
```
2023-03-07 04:00:17 +00:00
4. Restart systemd user service
```
systemctl --user restart modufur
```
2022-02-22 19:02:47 +00:00
## Uninstalling
2023-03-07 03:49:03 +00:00
1. Stop and disable systemd user service
```
systemctl --user disable --now modufur
```
2. Remove systemd user service file
```
rm ~/.config/systemd/user/modufur.service
```
3. Optionally disable lingering
```
sudo loginctl disable-linger username
```
4. Remove project folder
2022-02-21 20:53:10 +00:00
```
2023-03-17 06:15:14 +00:00
rm -rf modufur
2022-02-21 20:53:10 +00:00
```
2022-02-22 19:02:47 +00:00
## Contributing
1. [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repository on GitHub
2. Make changes to the code
2022-02-22 20:16:49 +00:00
3. Format the code with [Black](https://black.readthedocs.io/en/stable) inside the project folder
2022-02-22 19:28:12 +00:00
```
2023-03-16 21:56:44 +00:00
poetry run black .
2022-02-22 19:28:12 +00:00
```
2022-02-22 23:35:24 +00:00
4. [Commit](https://github.com/git-guides/git-commit) the changes to the fork
2022-02-22 19:28:12 +00:00
5. Create a [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) from the fork
2022-02-22 19:02:47 +00:00
## FAQ
### What happened to the public bot?
My Discord account was deleted, so a new bot had to be created.
2022-02-23 00:05:51 +00:00
### Why not link to the public bot here?
2022-02-22 19:02:47 +00:00
Although public, I do not wish for it to be excessively used due to API quotas.
2022-02-23 00:05:51 +00:00
### Why can't I send explicit images to the bot?
Discord currently has no way to disable scanning content for bots.\
You can send links uploaded elsewhere instead.
2022-02-21 07:10:57 +00:00
## Credits
[hikari](https://github.com/hikari-py/hikari)\
[hikari-lightbulb](https://github.com/tandemdude/hikari-lightbulb)\
[hikari-miru](https://github.com/HyperGH/hikari-miru)\
2023-03-07 02:36:21 +00:00
[songbird-py](https://github.com/magpie-dev/Songbird-Py)\
2022-02-21 07:10:57 +00:00
[pysaucenao](https://github.com/FujiMakoto/pysaucenao)