Advertisement
Guest User

mimicbot

a guest
Oct 1st, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. irc = require('irc')
  3.  
  4. client = new irc.Client(
  5.     'irc.openredstone.org',
  6.     'mimicbot',
  7.     {
  8.         channels: ['#openredstone'],
  9.         userName: 'tbot8',
  10.         realName: 'The 8th tbot'
  11.     }
  12. )
  13.  
  14. graph = {}
  15.  
  16. client.addListener('message', (from, to, msg) ->
  17.     console.log(from, '->', to, ':', msg)
  18.  
  19.     if to == 'tbot8'
  20.         return
  21.  
  22.     if msg.match /~mimic/
  23.         sentence = [randomKey graph]
  24.         last = sentence[0]
  25.         while graph[last]
  26.             last = (randomElem(graph[last]))
  27.             sentence.push(last)
  28.             if sentence.length > 15 then break
  29.         client.say('#openredstone', sentence.join(' '))
  30.  
  31.         return
  32.  
  33.  
  34.  
  35.     if from.match /ORE/
  36.         chat = msg.substr((msg.indexOf ':') + 2)
  37.     else
  38.         chat = msg
  39.  
  40.     chat = chat.split(' ')
  41.     if chat.length <= 1 then return
  42.  
  43.     for i in [0 .. chat.length - 2]
  44.         if graph[chat[i]]
  45.             graph[chat[i]].push(chat[i + 1])
  46.         else
  47.             graph[chat[i]] = [ chat[i + 1] ]
  48.  
  49.     console.log(graph)
  50. )
  51.  
  52. randomElem = (arr) ->
  53.     arr[Math.floor(Math.random() * arr.length)]
  54.  
  55. randomKey = (obj) ->
  56.     randomElem Object.keys(obj)
  57.  
  58.  
  59.  
  60. setTimeout(() ->
  61.     client.say('NickServ', 'identify orepassword')
  62. , 1500)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement