From 025355b9d2be4a5dd0d447bee06a887942a3d479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20S=C3=A1nchez?= Date: Wed, 13 Oct 2021 17:46:25 +0200 Subject: [PATCH] =?UTF-8?q?update=20requirements=20y=20soluci=C3=B3n=20a?= =?UTF-8?q?=20mensajes=20de=20reporte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoficher.py | 12 ++++++------ autoficher.sh | 17 ----------------- requirements.txt | 3 ++- 3 files changed, 8 insertions(+), 24 deletions(-) delete mode 100755 autoficher.sh diff --git a/autoficher.py b/autoficher.py index 200b5ae..8855ce1 100755 --- a/autoficher.py +++ b/autoficher.py @@ -121,17 +121,17 @@ class AutoFicher(): response = self.post("check", data, self.headers) rj = json.loads(response.text) - if response.status_code != 200: - 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 response.status_code == 200: 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") + 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: + self.sendReport("No se ha podido fichar, la web no ha devuelto 200 OK") if __name__ == '__main__': diff --git a/autoficher.sh b/autoficher.sh deleted file mode 100755 index 85a7266..0000000 --- a/autoficher.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -sleep $(( ( RANDOM % 300 ) + 1 )) - -pin=$1 -typ=$2 -date=$(date +"%d/%m/%Y+%H:%M:%S") -#dateenc=$(urlencode $date) - -#login -token=$(curl --header "user: 4d805364-70d7-4608-bf2f-7bf7b3d32c04" --header "pass: $pin" https://timenet.gpisoftware.com/api/v1/cp/login --silent) -token="${token//\"}" - -#checks -response=$(curl -X POST -H "Content-type: application/x-www-form-urlencoded" -H "token: $token" -d "typ=$typ&date=$date&geoLatitude=41.3908992&geoLognitude=2.154496&geoError=" https://timenet.gpisoftware.com/api/v1/cp/checks --silent) - -echo $response diff --git a/requirements.txt b/requirements.txt index b856f1d..c84ee58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -python-telegram \ No newline at end of file +python-telegram-bot +pytz \ No newline at end of file