Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'xmpp4r/client'
- include Jabber
- Jabber::debug = true
- jid = JID::new('nsantorello@gmail.com')
- password = ' S@NDont3hbi@@TCH!'
- $cl = Client::new(jid)
- $cl.connect
- $cl.auth(password)
- $notified = []
- $quit_words = ['stop', 'quit', 'exit', 'fuck you', 'esc', 'kill', 'die', 'bye']
- def add_notified(user)
- print user
- ($notified.push user).uniq!
- end
- def rem_notified(user)
- $notified.delete user
- end
- def send_msg(to, msg)
- $cl.send Message::new(to, msg).set_type(:normal)
- end
- def broadcast(msg)
- $notified.each { |user| send_msg(user, msg) }
- end
- to = "nsantorello2@gmail.com"
- body = "started successfully!"
- send_msg(to, body)
- $cl.add_message_callback do |msg|
- # Remove a user who wants to be taken off notifications
- if (msg.body != nil && msg.body != "")
- #if (msg.from == "nsantorello2@gmail.com/gmail.60F21217")
- # broadcast (msg.body)
- if ($quit_words.any? { |w| w == msg.body.strip.downcase })
- rem_notified(msg.from)
- send_msg(msg.from, "Goodbye!")
- else
- add_notified(msg.from)
- send_msg(msg.from, "You are now receiving alerts!")
- end
- end
- end
- while true
- sleep(10000)
- end
Add Comment
Please, Sign In to add comment