dmzoneill/dmzoneill
Basename is uppercase README.mdComposite action step script body
SHA-2563bafe551455a4d4aced23934313ca31dec20e2089871d0fa52d4b5dd995efdee
Evidence
1"""Send a short Telegram notification given on the command line."""
2
3import os
4import sys
5
6import requests
7
8
9def main():
10 """Send the message from argv to the configured Telegram chat."""
11 if len(sys.argv) != 2:
12 print("Usage: python telegram-notify.py <message>")
13 sys.exit(1)
14
15 message = sys.argv[1]
16
17 # Remove "dmzoneill/" prefix if present
18 message = message.replace("dmzoneill/", "")
19 print(message)
20
21 # Configuration
22 bot_token = os.getenv("TELEGRAM_BOT_TOKEN")
23 chat_id = os.getenv("TELEGRAM_CHAT_ID")
24
25 if not bot_token or not chat_id:
26 print("Warning: TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID not set - skipping notification")
27 sys.exit(0)
28
29 url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
30 payload = {
31 "chat_id": chat_id,
32 "text": message,
33 }
34
35 try:
36 resp = requests.post(url, json=payload, timeout=30)
37 if resp.status_code == 429:
38 print(f"Telegram rate limited (429): {resp.text}")
39 sys.exit(0)
40 resp.raise_for_status()
41 print(f"Telegram response: {resp.json()}")
42 except requests.exceptions.RequestException as e:
43 print(f"Error sending message: {e}")
44 sys.exit(1)
45
46
47if __name__ == "__main__":
48 main()
1#!/usr/bin/env python3
2# pylint: disable=invalid-name
3# The hyphenated module name is part of the download URL used by every repo.
4"""Reply to new GitHub issues and pull requests with an AI-generated comment."""
5
6import json
7import os
8import shutil
9import subprocess
10import sys
11import tempfile
12
13import requests
14
15
16def get_issue_content(repo, issue_number, github_token):
17 """Fetch an issue's JSON from the GitHub API."""
18 url = f"https://api.github.com/repos/{repo}/issues/{issue_number}"
19 headers = {
20 "Authorization": f"token {github_token}",
21 "Accept": "application/vnd.github.v3+json",
22 }
23 response = requests.get(url, headers=headers, timeout=10)
24 response.raise_for_status()
25 data = response.json()
26 return data["title"], data["body"] or "", data["html_url"], data["user"]["login"]
27
28
29def get_pr_content(repo, pr_number, g …
47:10… Accept": "application/vnd.github.v3.diff",
48 }
49 response = requests.get(url, headers=headers, timeout=30)
50 response.raise_for_status()
51 diff = response.text
52 if len(diff) > 10000:
53 diff = diff[:10000] + "\n\n... (diff truncated)"
⋯4 lines
58:15… e the refresh token in a Google credentials file for an OAuth access token."""
59 with open(credentials_path, "r", encoding="utf-8") as f:
60 cred_data = json.load(f)
61
62 refresh_token = cred_data.get("refresh_token")
63 client_id = cred_data.get("client_id")
64 client_secret = cred_data.get("client_secret")
65
66 if not all([refresh_token, client_id, client_secret]):
67 raise ValueError("Invalid …
67:66… g client_id, client_secret, or refresh_token")
68
69 token_url = "https://oauth2.googleapis.com/token"
70 payload = {
71 "client_id": client_id,
72 "client_secret": client_secret,
73 "refresh_token": refresh_token,
74 "grant_type": "refresh_token",
75 }
76 resp = requests.post(token_url, data=payload, timeout=15)
77 resp.raise_for_status()
78 token_json = resp.json()
79
80 access_token = token_json.get("access_token")
81 quota_project = cred_data.get("quota_project_id") or os.getenv("GOOGLE_CLOUD_PROJECT")
82 return access_token, quota_project
83
84
85class OpenCodeCliError(RuntimeError):
86 """Failure from the official OpenCode CLI, cl …
No evidence locations were recorded for this file. Raw result