Skip to content

Kyouka is a simple and powerful music bot for KOOK(AKA KaiHeiLa), it is easy to use and develop.

License

Notifications You must be signed in to change notification settings

shuyangzhang/Kyouka

Repository files navigation

Kyouka 镜华 点歌机器人

GitHub last commit Release MIT license khl server github stars

Kyouka is a simple and powerful music bot for KOOK, 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

  • Multi platform
  • All async
  • Container as a service

Dependencies

  • Docker, whether you are deploying based on docker or binaries.
  • Python >= 3.9, if you wanna to deploy it based on source code.

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
  1. 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
  1. create container for Kyouka bot.
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

  1. 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
  1. 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
  1. install python dependencies.
# 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
  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.

Usage

Quick Start

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

Commands

  • /ping: check whether Kyouka is alive.
  • /help: get usage from Kyouka.
  • /debug: (only for admin) the debug switch.
  • /comehere: bind the voice channel you are in.
  • /channel {channel_id}: bind the voice channel with id.
  • /play {music_name}: add a music to play list.
  • /search {keyword}: search music by keyword from netease cloud music.
  • /msearch {keyword}: search music by keyword from migu music.
  • /qsearch {keyword}: search music by keyword from qq muisc.
  • /osearch {keyword}: search music by keyword from game osu!.
  • /select {search_list_id}: select a music from search result, then add it to play list.
  • /bilibili {bilibili_video_url}: add a video from Bilibili to play list.
  • /list: check the play list.
  • /cut: play the next music in play list.
  • /playlist {playlist_url}: import a netease cloud music play list to Kyouka.
  • /radio {radio_url}: import a netease cloud music radio list to Kyouka.
  • /album {album_url}: import a netease cloud music album to Kyouka.
  • /remove {list_id}: remove a music from play list.
  • /top {list_id}: place a music at the top of play list.

Development

Contributing

  • using the issue tracker
    Use the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution.

  • changing the code base
    Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All commit messages should satisfy Conventional Commits

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