Last active
July 2, 2019 08:24
-
-
Save blha303/c4cd254d7f4cc7e53b58013c5e2596d3 to your computer and use it in GitHub Desktop.
Asterisk 1.0.0.1 context
This file contains hidden or 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
[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() |
This file contains hidden or 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
#!/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