Last active
December 15, 2015 20:58
-
-
Save tobeportable/5321932 to your computer and use it in GitHub Desktop.
xm gem source file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "xm/version" | |
require 'xmpp4r' | |
require 'yaml' | |
module Xm | |
include Jabber | |
@@y = YAML.load_file(ENV['HOME']+'/.xm') | |
@@cl = Client.new(JID.new(@@y[:login])) | |
if @@y.has_key? :server | |
@@cl.connect(@@y[:server]) | |
else | |
@@cl.connect | |
end | |
@@cl.auth(@@y[:password]) | |
def xm_us msg | |
@@y[:us].each do |to| | |
xm_to to, msg | |
end | |
end | |
alias pp_us xm_us | |
def xm msg | |
to = @@y[:me] | |
xm_to to, msg | |
end | |
alias pp xm | |
def xm_to to, msg | |
msg = @@y[:header].gsub(/(`.*`)/) { eval($1).strip } + msg if @@y[:header] | |
@@cl.send Message::new( to, msg ).set_type(:chat).set_id('1') | |
end | |
alias pp_to xm_to | |
end | |
include Xm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment