Loading...
Loading...
Automatic response rules, patterns, and scheduled messages
npx skill4agent add alsk1992/cloddsbot auto-reply/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 diskimport { 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');| Type | Example | Description |
|---|---|---|
| | Contains keyword |
| | Exact match only |
| | Regular expression |
| | Starts with prefix |
| | Ends with suffix |
| Type | Description |
|---|---|
| Active during time window |
| Active on specific days |
| Only for specific users |
| Only in specific channels |
| Only for users with role |
| Custom function |
| Variable | Description |
|---|---|
| User display name |
| User ID |
| Channel name |
| Full regex match |
| First capture group |
| Current date |
| Current time |