-
Notifications
You must be signed in to change notification settings - Fork 1
/
DEK23_PHONE.py
109 lines (84 loc) · 2.9 KB
/
DEK23_PHONE.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os
from twilio.rest import Client
from twilio.base.exceptions import TwilioRestException
# Set environment variables for your Account Sid and Auth Token!
# These can be found at twilio.com/console
# Your Account SID from twilio.com/console
account_sid = "" # COLOCA ENTRE LAS COMILLAS TU ACCOUNT SID DE TWILIO
# Your Auth Token from twilio.com/console
auth_token = "" # COLOCA ENTRE LAS COMILLAS TU AUTH TOKEN DE TWILIO
client = Client(account_sid, auth_token)
# RECUERDA QUE PARA QUE FUNCIONA SPAM Y ROBOT DETECTOR DEBES INSTALAR EL PLUGIN NOMOROBO EN TWILIO ACCEDIENDO A TU CUENTA.
def presentation():
os.system('clear')
print(""" ********************
DEK23 PHONE
********************
Suigueme en Twitter: @rickdeckard23
Mi web: deckcard23.com""", end="\n\n")
def is_valid_number(number):
try:
response = client.lookups.phone_numbers(number).fetch(type="carrier")
return True
except TwilioRestException as e:
if e.code == 20404:
return False
else:
raise e
def datos_generales():
phone_number = client.lookups \
.phone_numbers(telefono) \
.fetch(type=['carrier'])
print(phone_number.carrier) # All of the carrier info.
print(phone_number.carrier['name']) # Just the carrier name.
def chequear_telefono(telefono):
number = client.lookups.phone_numbers(telefono).fetch()
print(number.national_format)
def line_type(phone_number):
"""
Args:
phone_number (string): phone number in e.164 format
Returns:
string: line type associated with the phone number
possible values are mobile, landline, or voip
"""
phone_number_type = client \
.lookups \
.phone_numbers(phone_number) \
.fetch(type='carrier') \
.carrier \
.get('type')
return phone_number_type
def robot_spam(phone_number):
phone_number = client.lookups \
.phone_numbers(phone_number) \
.fetch(add_ons='nomorobo_spamscore')
print(phone_number.add_ons)
def is_robocaller(phone_number):
"""
Args:
phone_number (string): phone number in e.164 format
Returns:
boolean: 'True' if robocaller
"""
spam_score = client \
.lookups \
.phone_numbers(phone_number) \
.fetch(add_ons='nomorobo_spamscore') \
.add_ons['results']['nomorobo_spamscore']['result']['score']
return spam_score == 1
presentation()
telefono = input('Introduce tu número de teléfono (ejemplo. +34666445533): ')
print("Datos generales: ", end="")
datos_generales()
print("Chequeo del telefono: ", end="")
chequear_telefono(telefono)
print("El teléfono es válido:", end="")
print(is_valid_number(telefono))
phone_number = telefono
print("La línea es del tipo: ", line_type(phone_number))
print("(landline=fija mobile=móvil VOIP=Voz por datos)")
print("Datos sobre spam: ", end="")
robot_spam(phone_number)
print("Datos sobre linea robot:", end="")
print(is_robocaller(telefono))