Telegram messages to report
This commit is contained in:
@@ -16,7 +16,7 @@ Como se usa?
|
||||
Parametros obligatorios
|
||||
---------------
|
||||
|
||||
- -u > Usuario de timenet (Pista Cero = 4c26cc59-ee52-4c47-b7fe-1065a5e5bf84)
|
||||
- -u > Usuario de timenet (Pista Cero = 4c26cc59-ee52-4c47-b7fe-1065a5e5bf84) (Lo he pasado a config.json)
|
||||
- -p > Pin de usuario
|
||||
|
||||
Tendremos que escojer también entre --basedtime o --type
|
||||
|
||||
@@ -7,11 +7,7 @@
|
||||
# Argumentos obligatorios:
|
||||
# -u USER, --user USER Usuario
|
||||
# -p PIN, --pin PIN Contraseña
|
||||
# -t TYPE, --type TYPE Tipo marcado. 0 = Entrada, 1 = Salida
|
||||
#
|
||||
# Argumentos opcionales:
|
||||
# -f, --festive Comprobar festivo
|
||||
# -h, --help Esta ayuda
|
||||
# -t TYPE, --type TYPE Tipo marcado. 0 = Entrada, 1 = Salida (Si no se utiliza -bt)
|
||||
#
|
||||
#
|
||||
# Creado: Omar Sánchez 04-05-2019
|
||||
@@ -31,7 +27,7 @@ parser = argparse.ArgumentParser(add_help=False)
|
||||
parser._action_groups.pop()
|
||||
|
||||
obligatoryArgs = parser.add_argument_group("Argumentos obligatorios")
|
||||
obligatoryArgs.add_argument('-u', '--user', help="Usuario", required=True)
|
||||
# obligatoryArgs.add_argument('-u', '--user', help="Usuario", required=True)
|
||||
obligatoryArgs.add_argument('-p', '--pin', help="Contraseña", type=int, required=True)
|
||||
obligatoryArgs.add_argument('-t', '--type', help="Tipo marcado. 0 = Entrada, 1 = Salida", type=int)
|
||||
|
||||
@@ -60,7 +56,7 @@ class AutoFicher():
|
||||
exit(20)
|
||||
|
||||
def loadConfig(self):
|
||||
with open('sample.config.json', 'r') as f:
|
||||
with open('config.json', 'r') as f:
|
||||
self.config = json.load(f)
|
||||
|
||||
def sendReport(self, message):
|
||||
@@ -111,7 +107,7 @@ class AutoFicher():
|
||||
typ = args.type
|
||||
|
||||
data = {
|
||||
"cp": args.user,
|
||||
"cp": self.config['user'],
|
||||
"pin": args.pin,
|
||||
"typ": typ,
|
||||
"date": self.headers['tn-d'],
|
||||
@@ -123,9 +119,17 @@ class AutoFicher():
|
||||
}
|
||||
|
||||
response = self.post("check", data, self.headers)
|
||||
rj = json.loads(response.text)
|
||||
|
||||
if response.status_code != 200:
|
||||
self.sendReport('Has fichado correctamente a las ' + str(datetime.strptime(self.headers["tn-d"]).strftime("%H:%M")))
|
||||
time = datetime.strptime(self.headers["tn-d"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.utc).astimezone(
|
||||
pytz.timezone("Europe/Madrid")).strftime("%H:%M")
|
||||
self.sendReport('Has fichado correctamente a las %s' % time)
|
||||
else:
|
||||
if rj['Repeated']:
|
||||
time = datetime.strptime(rj['RepeatedTime'], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.utc).astimezone(
|
||||
pytz.timezone("Europe/Madrid")).strftime("%H:%M")
|
||||
self.sendReport("Se ha realizado un marcaje antes a las %s" % time)
|
||||
else:
|
||||
self.sendReport("No se ha podido fichar, la web no ha devuelto 200 OK")
|
||||
|
||||
|
||||
@@ -23,5 +23,6 @@
|
||||
"latitude": 0,
|
||||
"longitude": 0,
|
||||
"accuracy": 0
|
||||
}
|
||||
},
|
||||
"user": "4c26cc59-ee52-4c47-b7fe-1065a5e5bf84"
|
||||
}
|
||||
Reference in New Issue
Block a user