-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtg_qr_document.py
More file actions
45 lines (36 loc) · 1.03 KB
/
tg_qr_document.py
File metadata and controls
45 lines (36 loc) · 1.03 KB
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
#!/usr/bin/env python3
"""PreToolUse hook: warn to send QR codes as document not photo on Telegram."""
import json
import re
import sys
def main():
try:
input_data = json.load(sys.stdin)
except (json.JSONDecodeError, EOFError):
print("{}")
return
tool_name = input_data.get("tool_name", "")
tool_input = input_data.get("tool_input", {})
# Check for TG reply tool with QR image
if "telegram" not in tool_name and "reply" not in tool_name:
print("{}")
return
files = tool_input.get("files", [])
if not files:
print("{}")
return
has_qr = any(
re.search(r'qr|login|scan', str(f), re.IGNORECASE)
for f in files
)
if has_qr:
print(json.dumps({
"systemMessage": (
"⚠️ **QR code detected.** Send as document (not photo) on Telegram — "
"photo compression can make QR codes unscannable."
)
}))
else:
print("{}")
if __name__ == "__main__":
main()