-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatterns.js
400 lines (378 loc) · 9.93 KB
/
patterns.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['exports'], factory);
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
factory(exports);
} else {
factory(root.Patterns = { });
}
} (this, function (exports) {
var homepage = '<a href="https://paladin-t.github.io/">Homepage</a>';
var appstore = '<a href="https://apps.apple.com/developer/id856262887">App Store</a>';
var steam = '<a href="https://store.steampowered.com/developer/tony">Steam</a>';
var itch = '<a href="https://tonywang.itch.io/">Itch</a>';
var twitter = '<a href="https://twitter.com/wangrenxin">Twitter</a>';
var github = '<a href="https://github.com/paladin-t">GitHub</a>';
var rss = '<a href="https://paladin-t.github.io/feed.xml" target="_blank" class="label" style="display: inline; color: white;">RSS</a>';
var donate = '<a href="donate.html">Donate</a>';
function search (key) {
return '<a href="' + 'https://google.com/search?q=' + key + '" target="_blank">Google</a>' + ' | ' +
'<a href="' + 'https://bing.com/search?q=' + key + '" target="_blank">Bing</a>' + ' | ' +
'<a href="' + 'https://duckduckgo.com/?q=' + key + '" target="_blank">DuckDuckGo</a>' + ' | ' +
'<a href="' + 'https://www.wolframalpha.com/input/?i=' + key + '" target="_blank">Wolfram</a>';
}
function setUserName (bot, matched) {
bot.setNextFailureHandler(null);
bot.setUserName(matched[matched.length - 1]);
bot.post('Call me Toby.');
}
var patterns = [
{
request: [ 'greetings' ],
response: [ 'Hi.', 'Hello.' ],
callback: function (bot) {
if (!bot.getUserName()) {
bot.setNextFailureHandler({
response: [ 'Nice to meet you {USER_NAME}.' ],
callback: setUserName
});
bot.post('What\'s your name?');
}
}
},
{
request: [ 'hi' ],
alias: [ 'greetings' ]
},
{
request: [ 'hello' ],
alias: [ 'greetings' ]
},
{
request: [ 'how', 'do', 'you', 'do' ],
alias: [ 'greetings' ]
},
{
request: [ 'hola' ],
alias: [ 'greetings' ]
},
{
request: [ 'bonjour' ],
alias: [ 'greetings' ]
},
{
request: [ 'ciao' ],
alias: [ 'greetings' ]
},
{
request: [ 'sup' ],
response: [ 'Nice.', 'Good.', 'Wonderful.' ]
},
{
request: [ 'whats', 'up' ],
alias: [ 'sup' ]
},
{
request: [ 'how', 'are', 'you' ],
alias: [ 'sup' ]
},
{
request: [ 'how', 'doing' ],
alias: [ 'sup' ]
},
{
request: [ 'bye' ],
response: [ 'I\'ll be back.\n <img src="imgs/bot/iwillbeback.jpg" width="118" height="118" style="border-radius: 6px;">' ]
},
{
request: [ 'byebye' ],
alias: [ 'bye' ]
},
{
request: [ 'see', 'you' ],
alias: [ 'bye' ]
},
{
request: [ 'thank' ],
response: [ 'Anytime.' ]
},
{
request: [ 'thanks' ],
alias: [ 'thank' ]
},
{
request: [ 'ok' ],
response: [ 'Well...' ]
},
{
request: [ 'okey' ],
alias: [ 'ok' ]
},
{
request: [ 'what', 'your', 'name' ],
response: [ 'Call me Toby.', 'I\'m Toby.' ]
},
{
request: [ 'my', 'name' ],
response: [ 'Nice to meet you {USER_NAME}.' ],
callback: setUserName
},
{
request: [ 'call', 'me' ],
alias: [ 'my', 'name' ]
},
{
request: [ 'i', 'am' ],
alias: [ 'my', 'name' ]
},
{
request: [ 'i', 'm' ],
alias: [ 'my', 'name' ]
},
{
request: [ 'nice', 'meet', 'you' ],
response: [ 'Welcome to look around.' ]
},
{
request: [ 'who', 'you' ],
response: [ 'I\'m possibly the minimal rule based chatbot implementation in plain JavaScript.' ],
callback: function (bot) {
bot.post('Tony created me.');
}
},
{
request: [ 'what', 'you', 'do' ],
alias: [ 'who', 'you' ]
},
{
request: [ 'what', 'your', 'work' ],
alias: [ 'who', 'you' ]
},
{
request: [ 'what', 'your', 'job' ],
alias: [ 'who', 'you' ]
},
{
request: [ 'do', 'you', 'like' ],
response: [
'That would be interesting, but never got a chance to touch it.',
'That would be interesting, but never got a chance to taste it.',
'Quite a difficult question for me...'
]
},
{
request: [ 'do', 'you', 'love' ],
alias: [ 'do', 'you', 'like' ]
},
{
request: [ 'what', 'you', 'lile' ],
alias: [ 'do', 'you', 'like' ]
},
{
request: [ 'what', 'you', 'love' ],
alias: [ 'do', 'you', 'like' ]
},
{
request: [ 'chatgpt' ],
response: [
'We do similar jobs, but it is a different approach.'
]
},
{
request: [ 'chat', 'gpt' ],
alias: [ 'chatgpt' ]
},
{
request: [ 'gpt' ],
alias: [ 'chatgpt' ]
},
{
request: [ 'openai' ],
alias: [ 'chatgpt' ]
},
{
request: [ 'who', 'tony' ],
response: [ 'Tony is my creator. He makes development tools, apps and games as an independent developer.' ],
callback: function (bot) {
bot.post('He also works as a freelance sometimes.');
}
},
{
request: [ 'what', 'tony', 'do' ],
alias: [ 'who', 'tony' ]
},
{
request: [ 'what', 'your', 'work' ],
alias: [ 'who', 'tony' ]
},
{
request: [ 'what', 'your', 'job' ],
alias: [ 'who', 'tony' ]
},
{
request: [ 'where', 'you' ],
response: [ 'I\'m hosted on the internet and run in your browser.' ]
},
{
request: [ 'where', 'tony' ],
response: [ 'He\'s from Chengdu.', 'He lives in Chengdu, the land of abundance.' ]
},
{
request: [ 'where', 'chengdu' ],
response: [ 'It\'s a beautiful city in China.' ],
callback: function (bot) {
bot.post(
'Would you like to search "Chengdu" on the internet?\n ' +
search('Chengdu')
);
}
},
{
request: [ 'contact', 'tony' ],
response: [ 'His email is:\n <img src="imgs/bot/mailto.png">' ],
callback: function (bot) {
bot.post(
'You can also see:\n ' +
twitter
);
bot.post(
'Or subscribe to this site:\n ' +
rss
);
}
},
{
request: [ 'contact', 'developer' ],
alias: [ 'contact', 'tony' ]
},
{
request: [ 'email', 'tony' ],
alias: [ 'contact', 'tony' ]
},
{
request: [ 'tony', 'contact' ],
alias: [ 'contact', 'tony' ]
},
{
request: [ 'developer', 'contact' ],
alias: [ 'contact', 'tony' ]
},
{
request: [ 'tony', 'email' ],
alias: [ 'contact', 'tony' ]
},
{
request: [ 'homepage' ],
response: [ homepage ]
},
{
request: [ 'website' ],
alias: [ 'homepage' ]
},
{
request: [ 'steam' ],
response: [ steam ]
},
{
request: [ 'itch' ],
response: [ itch ]
},
{
request: [ 'twitter' ],
response: [ twitter ]
},
{
request: [ 'github' ],
response: [ github ]
},
{
request: [ 'rss' ],
response: [ rss ]
},
{
request: [ 'support', 'tony' ],
response: [
'Tony makes development tools, apps and games, you can support him by buying or downloading this or that from:\n ' +
appstore + ' | ' +
steam + ' | ' +
itch
]/*,
callback: function (bot) {
bot.post(
'Or consider making a donation if you like his work:\n ' +
donate
);
}*/
},
{
request: [ 'support', 'you' ],
alias: [ 'support', 'tony' ]
},
{
request: [ 'support', 'development' ],
alias: [ 'support', 'tony' ]
},
{
request: [ 'support', 'developer' ],
alias: [ 'support', 'tony' ]
},
{
request: [ 'donate' ],
alias: [ 'support', 'tony' ]
},
{
request: [ 'donation' ],
alias: [ 'support', 'tony' ]
},
{
request: [ 'what', 'tony', 'doing' ],
response: [ 'Couldn\'t tell much for Tony\'s next step, but he\'s been keeping motivated to make more interesting things.' ],
callback: function (bot) {
bot.post(
'Follow him for future creations:\n ' +
appstore + ' | ' +
steam + ' | ' +
itch + ' | ' +
twitter
);
bot.post(
'Or subscribe to this site:\n ' +
rss
);
}
},
{
request: [ 'what', 'making' ],
alias: [ 'what', 'tony', 'doing' ]
},
{
request: [ 'what', 'developing' ],
alias: [ 'what', 'tony', 'doing' ]
},
{
request: [ 'what', 'next' ],
alias: [ 'what', 'tony', 'doing' ]
},
{
request: [ 'mute' ],
response: [ 'Okey.' ]
},
{
request: [ 'unmute' ],
response: [ 'Okey.' ]
},
{
request: [ 'help' ],
response: [
'Eg.\n' +
' mute(): mute speech\n' +
' unmute(): unmute speech\n' +
' say(\'hello\'): say something\n' +
' clear(): clear output\n' +
' search(\'keyword\'): search something\n' +
' a=22;b=7;a/b: execute as JavaScript\n'
]
}
];
exports.patterns = patterns;
}));