Mayafey Bot Documentation

website·Indexed 31 days ago

https://mayafey.shinelight.xyz/

Documentation for Mayafey, an open-source group chat bot based on Nonebot2 and go-cqhttp. Includes guides for installation on Windows and Ubuntu 20.04, configuration of API keys, plugin standards, and usage of the mayafey_webui management panel.

Tokens
12K
Snippets
86
Records
119
Agent score
49%

What's inside Mayafey

  1. Understand bot command prefixes and permission levels

    By default, most bot commands must be prefixed with a /. This prefix can be changed or removed in the bot configuration. The bot uses a hierarchical permission system to control access to features: Van (Root User) > Owner > Admin > Superuser > Member > Banned. All features are managed on a per-group basis to prevent data confusion.
  2. MayaFey Bot Technical Overview and Compatibility

    MayaFey is a group chat bot built using Nonebot2 and go-cqhttp. It is specifically optimized for group chat environments; while some private chat functions exist, most features are not guaranteed to work in private messages. It is currently only officially compatible with go-cqhttp, though other OneBot implementations may be attempted at the user's own risk regarding compatibility.
  3. Run the bot on Linux using screen

    Use screen to manage the bot and its dependencies in the background on Linux:

    1. Start go-cqhttp: Enter the go-cqhttp directory, run screen -R gocq, and execute ./go-cqhttp. Press Ctrl + A + D to detach.
    2. Start the Bot: Enter the bot directory, run screen -R bot, and execute poetry run python3 bot.py.
    3. Start Genshin Prayer API (Optional): Enter the API directory, run screen -R bot, and execute the dotnet command. Press Ctrl + A + D to detach.

    To return to the bot terminal, use screen -R bot.

    # Start go-cqhttp
    screen -R gocq
    ./go-cqhttp
    
    # Start Bot
    screen -R bot
    poetry run python3 bot.py
    
    # Start Genshin Prayer API (Optional)
    screen -R bot
    dotnet GenshinPray.dll --launch-profile Production --urls http://0.0.0.0:8081
  4. Install the optional Genshin Pray API

    Set up the GenshinPray API to enable wish-tracking features. This requires .NET 6.0 and a MySQL database.
    cd /nonebot
    git clone https://github.com/GardenHamster/GenshinPray.git
    cd GenshinPray/GenshinPray
    mv PrayMaterial /nonebot/GenshinPray/PrayMaterial
    mv Sql/initData.sql /nonebot/GenshinPray/initData.sql
    mv Fonts/zh-cn.ttf /usr/share/fonts
    fc-cache
    cd ..
    rm -rf GenshinPray
    cd ..
    # Replace {releases} with the latest release URL from GitHub
    wget {releases}
    unzip GenshinPray.zip
    rm -f GenshinPray.zip
    
    # Install .NET 6.0
    wget https://dot.net/v1/dotnet-install.sh
    sudo bash dotnet-install.sh -c 6.0 --runtime aspnetcore
    ln -s $HOME/.dotnet/dotnet /usr/bin/dotnet
    
    cd GenshinPray
    apt install -y libgdiplus
    
    # Initialize database
    mysql -uroot -pYourPassword genshinpray < initData.sql
    
    # Run the API
    dotnet GenshinPray.dll --launch-profile Production --urls http://0.0.0.0:8081
  5. Install the MayaFey Bot core

    Install the bot core using Git and Poetry for dependency management.
    apt -y install git
    cd /nonebot
    git clone https://github.com/Shine-Light/Nonebot_Bot_MayaFey.git
    mv Nonebot_Bot_MayaFey bot
    cd bot
    poetry install
  6. Manage the Points (Credit) system

    The system includes a points economy where users can earn points via sign-ins, mini-games, or red packets, and transfer points to others.
    /我的积分        # View my points
    /积分排行榜       # View top 10 leaderboard
    /发红包 {amount} {count} # Send point red packet
    /抢红包           # Claim point red packet
    /转账 {amount} {@user}    # Transfer points to user
    /签到             # Earn points via daily sign-in (Member+)
  7. Translate Text using Tencent or Baidu

    Baidu Translation Parameters:

    • x: Language code (e.g., 中, 英, 粤, 日, 韩, 法, etc.). The first x can be 'x' for auto-detection; the second must be a specific language.
    • text: Content to translate (maximum 2000 characters).
    # Tencent Version
    /腾讯翻译 {text}
    
    # Baidu Version
    {lang1}译{lang2} {text}
    # Example: 中译英 Hello (Chinese to English)
    # Example: x译英 Hello (Auto-detect to English)
  8. Configure custom scheduled tasks

    Superusers can create, modify, and manage scheduled tasks. Tasks support three modes: '定时' (Daily at a specific time), '间隔' (Every n intervals), and '日期' (A specific one-time date/time).
    # Add a new task
    /新增定时任务 {title} {mode} {time} {content}
    
    # Modify an existing task
    /修改定时任务 {title} {mode} {time} {content}
    
    # Enable or disable a task
    /开启定时任务 {title}
    /关闭定时任务 {title}
    
    # Delete a task
    /删除定时任务 {title}
    
    # List all scheduled tasks
    /定时任务列表
    
    # Clean up expired tasks (only affects '日期' mode)
    /清理过期定时任务
  9. Install Python 3.9 and pip3 on Ubuntu

    Install Python 3.9 and set it as the default python3 command, then install pip3 and configure the Tsinghua mirror for faster downloads.
    # Install Python 3.9
    apt install -y python3.9
    ln -s /bin/python3.9 /bin/python3
    
    # Install pip3
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py
    ln -s /bin/pip /bin/pip3
    
    # Configure pip3 mirror
    pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  10. Prevent account risk when starting the bot

    To avoid account risk (wind control/ban), it is recommended to run go-cqhttp alone for 3 to 5 days after installation before starting the bot.
  11. Install Poetry and Screen

    Install Poetry for dependency management and Screen for maintaining persistent terminal sessions.
    # Install Poetry
    pip3 install poetry
    
    # Install Screen
    apt install -y screen
  12. Manage member disciplinary records (Demerits)

    The system allows superusers to track and manage member demerits (记过). Members can view their own records and the current group configuration.
    # Superuser: Record demerits for one or more members
    /记过 {@user1} {@user2} {reason}
    
    # Superuser: View a specific member's demerit record
    /查找记过记录 {@user}
    
    # Member+: View my own demerit records
    /我的记过记录
    
    # Member+: View group demerit configuration
    /记过配置
    
    # Superuser: Modify group demerit configuration
    /修改记过配置 {item} {parameter}