tSIP softphone: number preprocessing

Number dialed by tSIP can processed (or changed altogether) with "on make call" script. Lua SetCallTarget function was added in tSIP 0.1.69.2. Example below removes from dialed string/number/URI all characters except 0...9, *, #, A, B, C and D - intended to remove unexpected characters from dialed number when using "typical"/"numeric" extension identifiers:

target = GetInitialCallTarget()
print(string.format("Initial target: %s\n", target))
target = target:gsub("[^0123456789*#ABCD]", "")
print(string.format("Processed target: %s\n", target))
SetCallTarget(target)    
  

Example adding "33" prefix if dialed number contains two digits:

 
local target = GetInitialCallTarget()
print(string.format("Initial target: %s\n", target))
target = target:gsub("[^0123456789*#ABCD]", "")
 
print(string.format("Target cleaned length = %d\n", string.len(target)))
if string.len(target) == 2 then
	target = "33" .. target
end
 
print(string.format("Processed target: %s\n", target))
SetCallTarget(target)
  

Back to howto list