-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.js
207 lines (186 loc) · 5.23 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
var ChatBot = require('./lib/chatBot').ChatBot;
// This will log in a steam user with the specified username and password
// You can also pass in a steam guard code from an email
var myBot = new ChatBot('username', 'password', { guardCode: 'XXXXX', autoReconnect: true });
// Set up the triggers to control the bot
myBot.addTriggers([
// Commands to stop/unstop the bot from saying anything in a chatroom
{
name: 'MuteCommand',
type: 'BotCommandTrigger',
options: {
matches: ['!mute', '!pause'],
exact: true,
callback: function(bot) { bot.mute(); }
}
},
{
name: 'UnmuteCommand',
type: 'BotCommandTrigger',
options: {
matches: ['!unmute', '!unpause'],
exact: true,
callback: function(bot) { bot.unmute(); }
}
},
// Command to join Bad Rats whenever it's mentioned
{
name: 'BadRatsCommand',
type: 'BotCommandTrigger',
options: {
matches: ['bat rats'],
exact: false,
callback: function(bot) { bot.joinGame(34900); }
}
},
// Automatically accept invites from any user to the specified group chat
{
name: 'AcceptChatInvite',
type: 'AcceptChatInviteTrigger',
options: {
chatrooms: { 'GroupSteamId': 'Welcome message' },
autoJoinAfterDisconnect: true
}
},
// Automatically accept all friend requests
{ name: 'AcceptFriendRequest', type: 'AcceptFriendRequestTrigger' },
// Reply triggers - respond to a chat/private message if it matches a set of inputs
// (case-insensitive exact or substring match), and choose randomly from a set of responses
{
name: 'EmptyQuoteReply',
type: 'ChatReplyTrigger',
options: {
matches: ['^'],
responses: ['^'],
exact: true,
delay: 1000,
probability: 0.2,
timeout: 10*1000
}
},
{
name: 'HeartReply',
type: 'ChatReplyTrigger',
options: {
matches: ['<3'],
responses: ['</3', '<3'],
exact: true,
delay: 500,
probability: 0.5,
timeout: 60*60*1000 } },
{
name: 'SteveHoltReply',
type: 'ChatReplyTrigger',
options: {
matches: ['steve holt', 'steve holt!'],
responses: ['\\o/'],
exact: false,
delay: 500,
timeout: 10*1000
}
},
// Reply triggers that will only respond to a particular user
{
name: 'SingleUserReply',
type: 'ChatReplyTrigger',
options: {
matches: ['hi bot'],
responses: ['hi boss!'],
exact: true,
users: ['76561197961244239']
}
},
// Sample regex trigger, "mate" will be responded to with "mmaaaate",
// "mmaaaate" will be responded to with "mmmaaaaaaate", etc
{
name: 'MateEscalation',
type: 'RegexReplaceTrigger',
options: { match: /^(m+?)(a+?)te(s??)$/, response: '{0}m{1}aaate{2}', delay: 500}
},
// Butt bot, replace a random word from someone's message with "butt" about once every 50 messages
{
name: 'ButtBot',
type: 'ButtBotTrigger',
options: { replacement: 'butt', probability: 0.02, delay: 1000 }
},
// Chat reply that doesn't need a particular message to trigger, just a random reply about
// once every 100 messages (and no more than once an hour)
{
name: 'RandomReply',
type: 'ChatReplyTrigger',
options: {
matches: [],
responses: ['ლ(ಠ益ಠლ)', 'щ(゚Д゚щ)', 'omg', '(ノಥ益ಥ)ノ', '¯\\_(ツ)_/¯'],
delay: 500,
probability: 0.01,
timeout: 60*60*1000
}
},
// Cleverbot reply that only happens when the word "cleverbot" is mentioned
{
name: 'DirectCleverbotReply',
type: 'CleverbotTrigger',
options: { keywords: ['cleverbot'] }
},
// Random cleverbot reply that triggers randomly about once every 100 messages
{
name: 'RandomCleverbotReply',
type: 'CleverbotTrigger',
options: { probability: 0.01, timeout: 30*60*1000 }
},
// Say something when a user joins chat
{
name: 'SteveHoltEnter',
type: 'MessageOnJoinTrigger',
options: {
user: '76561197961244239',
message: "STEVE HOLT! \\o/",
probability: 0.5,
delay: 1000,
timeout: 24*60*60*1000
}
},
// Query Wolfram Alpha when a message starts with !wolfram
{
name: 'WolframReply',
type: 'WolframAlphaTrigger',
options: { command: '!wolfram', appId: 'XXXXXX' }
},
// Post all links from chat to tumblr, and also post things on command
{
name: 'TumblrTrigger',
type: 'TumblrTrigger',
options: {
autoPost: true,
autoPostContext: false,
blogName: 'XXX',
consumerKey: 'XXX',
consumerSecret: 'XXX',
token: 'XXX',
tokenSecret: 'XXX'
}
},
// Search YouTube and respond with the top result whenever someone types !yt <query>, rickroll about 1 every 100 times
{
name: 'Youtube',
type: 'YoutubeTrigger',
options: { command: '!yt', rickrollChance: 0.01, apiKey: 'XXX' }
},
// Search Google and respond with the top result whenever someone types !g <query>
{
name: 'Google',
type: 'GoogleTrigger',
options: { command: '!g', csiId: 'XXX', apiKey: 'XXX' }
},
// Search Google Images and respond with the top result whenever someone types !gi <query>
{
name: 'GoogleImages',
type: 'GoogleImagesTrigger',
options: { command: '!gi', csiId: 'XXX', apiKey: 'XXX' }
}
]);
myBot.connect();
// Trigger details can be retrieved and reloaded so that external configuration can be supported
var details = myBot.getTriggerDetails();
myBot.clearTriggers();
myBot.addTriggers(details);