Guest User

Untitled

a guest
Dec 8th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.22 KB | None | 0 0
  1. require 'xmpp4r/client'
  2. include Jabber
  3.  
  4. Jabber::debug = true
  5. jid = JID::new('nsantorello@gmail.com')
  6. password = ' S@NDont3hbi@@TCH!'
  7. $cl = Client::new(jid)
  8. $cl.connect
  9. $cl.auth(password)
  10.  
  11. $notified = []
  12. $quit_words = ['stop', 'quit', 'exit', 'fuck you', 'esc', 'kill', 'die', 'bye']
  13.  
  14. def add_notified(user)
  15.     print user
  16.     ($notified.push user).uniq!
  17. end
  18.  
  19. def rem_notified(user)
  20.     $notified.delete user
  21. end
  22.  
  23. def send_msg(to, msg)
  24.     $cl.send Message::new(to, msg).set_type(:normal)
  25. end
  26.  
  27. def broadcast(msg)
  28.     $notified.each { |user| send_msg(user, msg) }
  29. end
  30.  
  31. to = "nsantorello2@gmail.com"
  32. body = "started successfully!"
  33. send_msg(to, body)
  34.  
  35. $cl.add_message_callback do |msg|
  36.     # Remove a user who wants to be taken off notifications
  37.     if (msg.body != nil && msg.body != "")
  38.         #if (msg.from == "nsantorello2@gmail.com/gmail.60F21217")
  39.         #    broadcast (msg.body)
  40.         if ($quit_words.any? { |w| w == msg.body.strip.downcase })
  41.             rem_notified(msg.from)
  42.             send_msg(msg.from, "Goodbye!")
  43.         else
  44.             add_notified(msg.from)
  45.             send_msg(msg.from, "You are now receiving alerts!")
  46.         end
  47.     end
  48. end
  49.  
  50. while true
  51.     sleep(10000)
  52. end
Add Comment
Please, Sign In to add comment