1. Randomizing of GV account selection
2. Repeating the call using "next" GV account if current call failed
Here is the code:
Code: Select all
# Google Voice accounts: login, password, callback number, match, phone type, callback tmo
GVaccounts = [
['me1@gmail.com','pass1','1747xxxxxxx','.*',7,15],
['me2@gmail.com','pass2','1206xxxxxxx','.*',1,10],
]
def gvcall(num,acnt)
a = GVaccounts[acnt % GVaccounts.length] # fetch params
sys.GoogleVoiceCall(*((a[0,3] << num) + a[3,10])) # insert number as 4th param
end
Code: Select all
num = req.URI.User.to_s
r = Time.now.to_i
gvcall num,r
gvcall num,r+1
If you have just one Google Voice login/password but several callback numbers (Gizmo5, Sipgate, IPKall), you can do like this:
Code: Select all
GV_email = 'me@gmail.com'
GV_pwd = 'gmailpassword'
GV_num = '408xxxxxxx'
GVaccounts = [
[GV_email,GV_pwd,'1747xxxxxxx','.*',7], #callback to Gizmo5
[GV_email,GV_pwd,'1206xxxxxxx','.*'], #callback to IPKall
[GV_email,GV_pwd,'1415xxxxxxx','.*'], #callback to Sipgate
]
Code: Select all
num = req.URI.User.to_s
r = Time.now.to_i
2.times { |x| gvcall num,r+x }
Update 2009/11/19: Minor changes to accomodate pattern match and new "phone type" parameter.
Update 2009/11/23: Yet another approach to the problem, using Ruby hash to store parameters.
It's been quite a number of changes to sys.GoogleVoiceCall syntax (new parameters, removing old parameters etc) and every change required my attention to the matters. So, I decided to rewrite the code to make it easier to maintain:
Code: Select all
class Hash; alias :+ :merge; end
MyGV = { :usr => 'me@gmail.com',
:pwd => 'pass',
}
GVaccounts = [
MyGV + { :cb => '1747xxxxxxx', :type => 'Gizmo', :tmo => 15 },
MyGV + { :cb => '1206yyyyyyy' },
]
def gvcall(num,acnt)
a = {:num => num, :type => 'Home', :tmo => 8, :match => '.*'} # init with num & default values
a.update(GVaccounts[acnt % GVaccounts.length]) # add other params
a[:type] = {'Home' => 1, 'Mobile' => 2, 'Work' => 3, 'Gizmo' => 7}[a[:type]] # Encode type
sys.GoogleVoiceCall *a.values_at(:usr, :pwd, :cb, :num, :match, :type, :tmo)
end
Yet another version of this code is published on page 4 of this thread.