-
Notifications
You must be signed in to change notification settings - Fork 0
/
clonebot.coffee
38 lines (31 loc) · 1.15 KB
/
clonebot.coffee
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
{merge} = require './util'
@factory = (Bot) ->
class @CloneBot extends Bot
suffixes: ['o', 'a', 'e', 'i', 'u', 'y', 'ina', 'icus', 'ando', 'emoto', 'oni', 'r']
constructor: ({parentConfig, targetNick, service, channel}) ->
# select an available nick based on the target nick
nickIsTaken = true
i = 0
while nickIsTaken and i < @suffixes.length
suffix = @suffixes[i++]
cloneNick = targetNick + suffix
nickIsTaken = service.nicksByChannel[channel]?[cloneNick]
console.log "cloning #{targetNick} as #{cloneNick} in #{channel}"
service.say channel, "Cloning #{targetNick}"
ircServerOptions = merge service.options,
channels: [channel]
servers: null
nick: cloneNick
nickServPassword: null
userName: cloneNick
realName: "clone of #{targetNick}"
chattiness: 0
super merge parentConfig,
imitate: targetNick
skiplog: 'silent'
api: false
irc:
servers: [ircServerOptions]
@registerCommand 'quit', @_quitCommand
_quitCommand: (args, service, from, channel) ->
@quit "Terminated by #{from}"