Skip to content

Instantly share code, notes, and snippets.

@pong106
Last active April 14, 2025 09:29
Show Gist options
  • Save pong106/3932ffe20fa21af7110ff2deee242fd3 to your computer and use it in GitHub Desktop.
Save pong106/3932ffe20fa21af7110ff2deee242fd3 to your computer and use it in GitHub Desktop.
# === CONFIGURATION ===
APP_URL = com.dequantumcat.mobileattendance
PIN = 555555
MESSAGE = Attendance clocked in
SCREEN_CENTER_X = 520
# Set these in your environment or .env file
TELEGRAM_BOT_TOKEN ?= $(error TELEGRAM_BOT_TOKEN is not set)
TELEGRAM_CHAT_ID ?= $(error TELEGRAM_CHAT_ID is not set)
# === UTILS ===
define send_telegram
curl -s -X POST https://api.telegram.org/bot$(TELEGRAM_BOT_TOKEN)/sendMessage \
-d chat_id=$(TELEGRAM_CHAT_ID) \
-d text="$(1)"
endef
define send_telegram_photo
curl -s -X POST https://api.telegram.org/bot$(TELEGRAM_BOT_TOKEN)/sendPhoto \
-F chat_id=$(TELEGRAM_CHAT_ID) \
-F photo="@$(1)" \
-F caption="$(2)"
endef
.PHONY: telegram ss s10 power pin app kill navi clock dry run test
# === TELEGRAM ===
telegram:
$(call send_telegram, $(MESSAGE))
ss:
adb exec-out screencap -p > screen.png
sleep 0.5
$(call send_telegram_photo, screen.png, $(MESSAGE))
# === DEVICE CONTROL ===
s10:
sleep 10 # wait for GPS lock
power:
adb shell input keyevent 26
sleep 0.5
pin:
adb shell input keyevent 82
sleep 0.5
adb shell input text $(PIN)
sleep 0.5
# === APP CONTROL ===
app:
adb shell am force-stop $(APP_URL)
sleep 0.5
adb shell monkey -p $(APP_URL) 1
sleep 3 # wait for app to load
kill:
adb shell am force-stop $(APP_URL)
# === APP NAVIGATION ===
navi:
adb shell input tap $(SCREEN_CENTER_X) 1450 # Open auth
sleep 0.5
adb shell input tap $(SCREEN_CENTER_X) 1200 # Cancel prompt
sleep 0.5
adb shell input tap $(SCREEN_CENTER_X) 1450 # Use PIN
sleep 0.5
adb shell input text $(PIN)
sleep 0.5
adb shell input tap $(SCREEN_CENTER_X) 2100 # Attendance
sleep 0.5
clock: s10
adb shell input tap $(SCREEN_CENTER_X) 1350 # Clock in
sleep 0.5
# === WORKFLOWS ===
dry: power pin app navi s10 ss kill power
run: power pin app navi clock ss kill power
test:
@echo "✅ Makefile is working"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment