Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- irc = require('irc')
- client = new irc.Client(
- 'irc.openredstone.org',
- 'mimicbot',
- {
- channels: ['#openredstone'],
- userName: 'tbot8',
- realName: 'The 8th tbot'
- }
- )
- graph = {}
- client.addListener('message', (from, to, msg) ->
- console.log(from, '->', to, ':', msg)
- if to == 'tbot8'
- return
- if msg.match /~mimic/
- sentence = [randomKey graph]
- last = sentence[0]
- while graph[last]
- last = (randomElem(graph[last]))
- sentence.push(last)
- if sentence.length > 15 then break
- client.say('#openredstone', sentence.join(' '))
- return
- if from.match /ORE/
- chat = msg.substr((msg.indexOf ':') + 2)
- else
- chat = msg
- chat = chat.split(' ')
- if chat.length <= 1 then return
- for i in [0 .. chat.length - 2]
- if graph[chat[i]]
- graph[chat[i]].push(chat[i + 1])
- else
- graph[chat[i]] = [ chat[i + 1] ]
- console.log(graph)
- )
- randomElem = (arr) ->
- arr[Math.floor(Math.random() * arr.length)]
- randomKey = (obj) ->
- randomElem Object.keys(obj)
- setTimeout(() ->
- client.say('NickServ', 'identify orepassword')
- , 1500)
Add Comment
Please, Sign In to add comment