Skip to content

Instantly share code, notes, and snippets.

@blha303

blha303/1001.conf

Last active Jul 2, 2019
Embed
What would you like to do?
Asterisk 1.0.0.1 context
[1001]
exten => _X.,1,Set(CALLERID(name)=1.0.0.1)
exten => _X.,n,Answer
exten => _X.,n,Wait(1)
exten => _X.,n,Playback(1001-recordtype) ; "Enter record type on your phone keypad, followed by the hash key. Press 1 to go to next character"
exten => _X.,n,Read(recordtype,,,si,)
exten => _X.,n,Playback(1001-domain) ; "Enter domain name to retrieve record, followed by the hash key"
exten => _X.,n,Read(domain,,,si,)
exten => _X.,n,Set(RECORD="${SHELL(/usr/bin/1001.py "${recordtype}")}")
exten => _X.,n,Set(ADDR="${SHELL(/usr/bin/1001.py "${domain}")}")
exten => _X.,n,SayPhonetic("${ADDR}")
exten => _X.,n,Playback(1001-result) ; "Result"
exten => _X.,n,SayPhonetic("${SHELL(/usr/bin/dig +short "${ADDR}" "${RECORD}" @1.0.0.1 | tr ':' 'k')}")
exten => _X.,n,Wait(1)
exten => _X.,n,Playback(1001-partnership) ; "1.1.1.1 is a partnership between Cloudflare and APNIC but don't ask them for support with this phone number"
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup()
#!/usr/bin/env python
# please submit complaints about this code to /dev/null
from sys import argv,stdout
out = ""
newchar = False
for char in argv[1]:
if char == "*":
out += "."
continue
if char == "1":
newchar = True
continue
if char == "2":
l = "abc"
if char == "3":
l = "def"
if char == "4":
l = "ghi"
if char == "5":
l = "jkl"
if char == "6":
l = "mno"
if char == "7":
l = "pqrs"
if char == "8":
l = "tuv"
if char == "9":
l = "wxyz"
if not out or newchar or out[-1] not in l:
out += l[0]
else:
try:
out = out[:-1] + l[l.index(out[-1])+1]
except IndexError:
out = out[:-1] + l[0]
newchar = False
continue
stdout.write(out)
stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.