Skip to content

Instantly share code, notes, and snippets.

@blha303
Last active July 2, 2019 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blha303/c4cd254d7f4cc7e53b58013c5e2596d3 to your computer and use it in GitHub Desktop.
Save blha303/c4cd254d7f4cc7e53b58013c5e2596d3 to your computer and use it in GitHub Desktop.
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