shuyangzhang / Kyouka

Kyouka is a simple and powerful music bot for KOOK(AKA KaiHeiLa), it is easy to use and develop.
MIT License
115 stars 35 forks source link
bot kaiheila kaiheila-bot kook kook-bot music-bot python
# Kyouka 镜华 点歌机器人 ![GitHub last commit](https://img.shields.io/github/last-commit/shuyangzhang/Kyouka?logo=github) [![Release](https://img.shields.io/github/v/release/shuyangzhang/Kyouka)](https://github.com/shuyangzhang/Kyouka/releases) [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) [![khl server](https://www.kaiheila.cn/api/v3/badge/guild?guild_id=4648697392687523&style=3)](https://kaihei.co/oHRMIL) ![github stars](https://img.shields.io/github/stars/shuyangzhang/Kyouka?style=social) Kyouka is a simple and powerful music bot for [KOOK](https://www.kookapp.cn/), it is easy to use and develop.

Multilingual README

English | 中文

Contents

Statement

This repository is created just for learning python(Commercial prohibition).
All the apis used in this repository are from public network. So, if you wanna to listen the paid songs,
please open a paid member on corresponding music platform by yourself (respect the music copyright please).
Finally, if there are any infringements, please contact me to delete this repository.

Features

Dependencies

Installation and Deployment

Deploy based on docker service

I highly recommend you to deploy based on docker because it is easy to configure.

  1. if you havn't install docker, please follow these instructions.
  1. check if your docker is ready.
docker version
  1. pull the Kyouka bot image and khl-voice image.

    Kyouka bot image provides multi-architecture support for linux/amd64 and linux/arm64.
    khl-voice image only support for linux/amd64 arch.

If you are using Windows/x86_64, macos/amd64, macos/arm64, don't worry about that, you can also run images targeted for a different architecture on Docker Desktop.

docker pull shuyangzhang/kyouka
docker pull shuyangzhang/khl-voice
  1. copy the .env.template file from this repository or clone this repository, then rename it to .env.

    git clone https://github.com/shuyangzhang/Kyouka.git
    cd Kyouka
    mv .env.template .env
  2. configure the .env file.

    WARN: Do not insert any useless characters (including spaces, comments) at the end of the lines of configuration items, otherwise it will cause json parsing failure.

    
    # your bot token
    TOKEN=1/MECxOTk=/zCX2VjWr6p+AmD84jL9asQ==

default voice channel

CHANNEL=2559449076697969

the name of khl-voice sdk container, it should be different with your manager(bot) container name

CONTAINER_NAME=kyouka-runner

the admin user id list

ADMIN_USERS=["693543263"]

the file_logger switch

FILE_LOGGER=false


6. create container for Kyouka bot.
```bash
docker run --name kyouka-manager --env-file .env -v /var/run/docker.sock:/var/run/docker.sock --restart always -d shuyangzhang/kyouka
  1. now the bot in running, send a /ping command in your channel, if Kyouka reply you, that means your deployment is completed, enjoy!

    WARN: make sure that you have granted your bot read & send permissions.

Deploy based on source code

if you are using Win10/Win11, I highly recommend you to run these scripts in WSL2.

How to Install Linux on Windows with WSL

  1. same to step 1 of deploy based on docker service, install docker and check if it is ready.

    docker version

    make sure that you can run docker command without sudo. seeing Manage Docker as a non-root user

  2. pull the khl-voice image

docker pull shuyangzhang/khl-voice
  1. make sure you have installed Python, and its version >= 3.9

Download Python for your os

python -V
  1. clone this repository, then rename .env.template file to .env.

    git clone https://github.com/shuyangzhang/Kyouka.git
    cd Kyouka
    mv .env.template .env
  2. configure the .env file.

    WARN: Do not insert any useless characters (including spaces, comments) at the end of the lines of configuration items, otherwise it will cause json parsing failure.

    
    # your bot token
    TOKEN=1/MECxOTk=/zCX2VjWr6p+AmD84jL9asQ==

default voice channel

CHANNEL=2559449076697969

the name of khl-voice sdk container, it should be different with your manager(bot) container name

CONTAINER_NAME=kyouka-runner

the admin user id list

ADMIN_USERS=["693543263"]

the file_logger switch

FILE_LOGGER=false


6. install python dependencies.

```bash
# install vritualenv and initialize a venv for your bot
pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple
virtualenv venv

# activate venv
source venv/bin/activate

# install dependencies
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  1. run the Kyouka bot.

    python startup.py
  2. now the bot in running, send a /ping command in your channel, if Kyouka reply you, that means your deployment is completed, enjoy!

    WARN: make sure that you have granted your bot read & send permissions.

Usage

Quick Start

send a /help command in you channel, Kyouka will teach you how to use.

Commands

Development

Contributing

License

This project is licensed under the terms of the MIT license.

Community

If you need help, have any comments and suggestions, or want to develop Kyouka together, feel free to join our official community: https://kaihei.co/oHRMIL

Credits

This project is all based on khl.py