Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Server Usage

runoneall edited this page Feb 4, 2025 · 12 revisions
简体中文 | English
Language translations may not be 100% accurate

Import Module

from RyhBotPythonSDK import Server

Receive normal messages

@Server.Message.Normal
def NormalHandle(data):
    # Your Logic codes

Receive command message

@Server.Message.Command
def CommandHandle(data):
    # Your Logic codes

Add robot message

@Server.Message.BotFollowed
def BotFollowedHandle(data):
    # Your Logic codes

Delete robot messages

@Server.Message.BotUnFollowed
def BotUnFollowedHandle(data):
    # Your Logic codes

Robot Settings Message

@Server.Message.BotSettings
def BotSettingsHandle(data):
    # Your Logic codes

User join message

@Server.Message.GroupJoin
def GroupJoinHandle(data):
    # Your Logic codes

User exit message

@Server.Message.GroupLeave
def GroupLeaveHandle(data):
    # Your Logic codes

Button click message

@Server.Message.ButtonClick
def ButtonClickHandle(data):
    # Your Logic codes

All Type

@Server.Message.AllType
def AllTypeHandle(data):
    # Your Logic codes

Pre Call Function

def precall(data: dict):
    # Your Logic codes
    return data
Server.PreCall = precall

Run some scripts when a request comes in, such as modifying sender The precall function accepts a parameter representing the complete request body from the Yunhu server, but only the event field will be passed to the Server.Message decorator function

In addition to modifying the request body, this function can also terminate the response early, using the return keyword to return a string starting with !SERVER: with a response code, such as !SERVER:400 to return a 400 Bad Request error.

Start the service

# Your Logic codes

Server.Start(
    host = "Host"
    port = Port  # Int
    debug = (True / False) # Whether to enable debug mode
)

This document is written by English and 简体中文.

English


本文档由English和简体中文编写。

简体中文

Clone this wiki locally