Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Latest commit

 

History

History
51 lines (42 loc) · 935 Bytes

Repeater.md

File metadata and controls

51 lines (42 loc) · 935 Bytes

复读机

重复全部消息

using Maila.Cocoa.Framework;

[BotModule("Repeater")]
public class Repeater : BotModuleBase
{
    protected override bool OnMessage(MessageSource src, QMessage msg)
    {
        src.Send(msg.PlainText);
        return true;
    }
}

// <= abc
// => abc

实现 echo 指令

using Maila.Cocoa.Framework;

[BotModule("Repeater")]
public class Repeater : BotModuleBase
{
    // 手动发送:
    [RegexRoute("^/echo (?<content>.+)")]
    public static void Echo(MessageSource src, string content)
    {
        src.Send(content);
    }

    // 自动发送:
    // [RegexRoute("^/echo (?<content>.+)")]
    // public static string Echo(string content)
    // {
    //     return content;
    // }
    
    // 简化版自动发送:
    // [RegexRoute("^/echo (?<content>.+)")]
    // public static string Echo(string content) => content;
}

// <= /echo abcd
// => abcd