Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'xmpp4r'
- include Jabber
- class E2JBot
- def initialize(jid,jpasswd)
- @jid = jid
- @jpasswd = jpasswd
- @client = Client.new(JID::new(@jid))
- @client.connect
- @client.auth(@jpasswd)
- @client.send(Presence.new.set_type(:available))
- end
- def sendmsg (to, msg)
- @client.send(Message::new(to,msg))
- end
- def getmsg
- @client.add_message_callback do |m|
- sendmsg('xxxxxxxx@gmail.com',m.body)
- end
- end
- end
- bot = E2JBot.new('mybot@gmail.com','password')
- bot.sendmsg('xxxxxxxx@gmail.com','i am here!')
- bot.getmsg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement