mcpField
A
auto-reply

auto-reply

github.com/alsk1992生産性3.0k70 回インストール7 週間前に更新
リポジトリ

auto-reply について

auto-replyは、自動返信ルールを作成・管理するTypeScriptライブラリとコマンド群です。条件や時間設定、テンプレート変数を使って、メッセージに応じた返信を設定できます。

主な機能

  1. 01キーワード、完全一致、前方・後方一致、正規表現
  2. 02時間、曜日、ユーザー、チャンネル、ロールによる条件
  3. 03優先順位、スケジュール、クールダウン
  4. 04動的な返信変数
  5. 05ルールのテストと返信シミュレーション

活用シーン

  1. 01よくあるキーワードへの自動返信
  2. 02ユーザー、チャンネル、時間帯による返信制限
  3. 03ルール有効化前の一致結果の確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/alsk1992/cloddsbot --skill auto-reply

インストール後、Claude Code で/auto-replyを入力して読み込まれたか確認します。

同梱ファイルindex.ts

詳細

自動返信 - API リファレンス完全版

パターン、キーワード、条件に基づいた自動応答ルールを作成します。


チャットコマンド

ルールの一覧表示
/autoreply list                             List all rules
/autoreply active                           Show active rules only
/autoreply stats                            Rule statistics
ルールの作成
/autoreply add <pattern> <response>         Simple keyword match
/autoreply add-regex <regex> <response>     Regex pattern
/autoreply add-keywords <kw1,kw2> <resp>    Keyword rule
ルールの管理
/autoreply enable <id>                      Enable rule
/autoreply disable <id>                     Disable rule
/autoreply remove <id>                      Remove rule
/autoreply edit <id> <new-response>         Update response
/autoreply get <id>                         Rule details
テスト
/autoreply test <message>                   Test which rules match
/autoreply simulate <message>               Preview response
高度な設定
/autoreply cooldown <id> <seconds>          Set cooldown
/autoreply schedule <id> <start-end>        Active hours (e.g. 9-17)
/autoreply priority <id> <number>           Set priority (higher first)
/autoreply channel <id> <channel>           Restrict to channel
/autoreply clear-cooldowns                  Clear all cooldowns
/autoreply reload                           Reload rules from disk

TypeScript API リファレンス

自動返信マネージャーの作成
import { createAutoReplyManager } from 'clodds/auto-reply';

const autoReply = createAutoReplyManager({
  // Storage
  storage: 'sqlite',
  dbPath: './auto-reply.db',

  // Defaults
  defaultCooldownMs: 0,
  defaultPriority: 0,

  // Limits
  maxRulesPerUser: 100,
  maxResponseLength: 2000,
});
シンプルなルールの追加
// Keyword match
await autoReply.addRule({
  name: 'greeting',
  pattern: {
    type: 'keyword',
    value: 'hello',
    caseSensitive: false,
  },
  response: 'Hi there! How can I help?',
});
正規表現ルールの追加
// Regex pattern
await autoReply.addRule({
  name: 'price-query',
  pattern: {
    type: 'regex',
    value: /price\s+(btc|eth|sol)/i,
  },
  response: async (match, ctx) => {
    const symbol = match[1].toUpperCase();
    const price = await getPrice(symbol);
    return `${symbol} price: $${price}`;
  },
});
条件付きルールの追加
// With conditions
await autoReply.addRule({
  name: 'trading-hours',
  pattern: {
    type: 'keyword',
    value: 'trade',
  },
  conditions: [
    // Only during market hours
    {
      type: 'time',
      start: '09:30',
      end: '16:00',
      timezone: 'America/New_York',
    },
    // Only on weekdays
    {
      type: 'day',
      days: ['mon', 'tue', 'wed', 'thu', 'fri'],
    },
    // Only for certain users
    {
      type: 'user',
      userIds: ['user-123', 'user-456'],
    },
  ],
  response: 'Markets are open! What would you like to trade?',
  elseResponse: 'Markets are closed. Try again during trading hours.',
});
クールダウンの追加
// Prevent spam
await autoReply.addRule({
  name: 'faq',
  pattern: {
    type: 'keyword',
    value: 'faq',
  },
  response: 'Check our FAQ at https://...',
  cooldown: {
    perUser: 60000,    // 60s per user
    perChannel: 10000, // 10s per channel
    global: 5000,      // 5s global
  },
});
動的な応答
// Response with variables
await autoReply.addRule({
  name: 'welcome',
  pattern: {
    type: 'exact',
    value: '!welcome',
  },
  response: 'Welcome {{user.name}}! You joined {{user.joinDate}}.',
  variables: {
    'user.name': (ctx) => ctx.user.displayName,
    'user.joinDate': (ctx) => ctx.user.createdAt.toDateString(),
  },
});

// Response with API call
await autoReply.addRule({
  name: 'portfolio',
  pattern: {
    type: 'keyword',
    value: 'portfolio',
  },
  response: async (match, ctx) => {
    const portfolio = await getPortfolio(ctx.user.id);
    return `Your portfolio: $${portfolio.totalValue.toFixed(2)}`;
  },
});
ルールの一覧表示
const rules = await autoReply.listRules();

for (const rule of rules) {
  console.log(`${rule.id}: ${rule.name}`);
  console.log(`  Pattern: ${rule.pattern.value}`);
  console.log(`  Enabled: ${rule.enabled}`);
  console.log(`  Triggers: ${rule.triggerCount}`);
}
ルールのテスト
// Test which rules would match
const matches = await autoReply.test('hello world', {
  userId: 'user-123',
  channelId: 'telegram-456',
});

for (const match of matches) {
  console.log(`Rule: ${match.rule.name}`);
  console.log(`Response: ${match.response}`);
}
有効化/無効化
await autoReply.enable('rule-id');
await autoReply.disable('rule-id');
ルールの削除
await autoReply.deleteRule('rule-id');

パターンの種類

種類例説明
keywordhelloキーワードを含む
exact!help完全一致のみ
regex/price\s+\w+/i正規表現
startsWith!プレフィックスで始まる
endsWith?サフィックスで終わる

条件の種類

種類説明
time指定した時間帯に有効
day指定した曜日に有効
user指定したユーザーのみ
channel指定したチャンネルのみ
role指定したロールを持つユーザーのみ
customカスタム関数

応答変数

変数説明
{{user.name}}ユーザーの表示名
{{user.id}}ユーザー ID
{{channel.name}}チャンネル名
{{match[0]}}正規表現の完全一致
{{match[1]}}最初のキャプチャグループ
{{date}}現在の日付
{{time}}現在の時刻

ベストプラクティス

  1. 優先度を設定する — 重要なルールを先に適用します
  2. クールダウンを設定する — スパムを防止します
  3. パターンをテストする — 有効化する前に確認します
  4. 条件を使用する — コンテキストに応じた応答を実現します
  5. トリガーを監視する — ルールの有効性を確認します

コメント