Created
June 13, 2023 10:31
-
-
Save VB10/861107ec85775b52481f5061598168c2 to your computer and use it in GitHub Desktop.
send comment all issues to your repo with using chatgpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# GitHub API'ya gönderilecek olan veriler | |
base_url = "https://api.github.com/repos/{owner}/{repo}" | |
owner = "vb10" | |
repo = "2023-staj" | |
comment_body = f"""Merhaba arkadaşlar, sizler için elimden geldiğince herkese yazdım, LinkedIn postları paylaştım ve elimden gelen bir çok arkadaşa erişip staj bulmasına yardımcı oldum. Bu saate kadar size verebileceğim 'ben olsaydım' diyeceğim: | |
- Bu repoyu LinkedIn'de paylaşıp sadece kendim için değil, benim gibi arkadaşlar için staj arıyoruz demeniz. | |
- Unutmayın tek başınıza belki kimse görmez ama hepiniz aynı sesi çıkarabilirseniz, yine aranızdan bir arkadaş belki kazanır. | |
Ek olarak bir çoğunuzu inceledim, gördüm. Hepiniz bugüne kadar yaptıklarınız için ellerinize, emeklerinize sağlık. Staj bulamadın diyelim, okul uzadı vs. asla durma. Çalış, ayağa kalk. Düşmediğin sürece yenilmezsin. Kendimden biliyorum, tüm stajları red yemiş, naylon staj teklifi gelmiş vb. | |
Unutmayın: Umutsuz durumlar yoktur, umutsuz insanlar vardır. Ben hiç bir zaman umudumu yitirmedim! | |
Sevgilerimle, Repo önümüzdeki hafta gibi artık arşivlenecek. Bu staj dönemi bittiği için. Umarım tekrar böyle bir repo açmak zorunda kalmayız. | |
Güzellikler sizinle olsun. cc: """ | |
# GitHub API'ya gönderilecek olan istek başlıkları | |
headers = { | |
"Accept": "application/vnd.github.v3+json", | |
"Authorization": "Bearer YOUR_PERSONAL_ACCESS_TOKEN" | |
} | |
# İlk sayfayı al | |
response = requests.get(base_url.format(owner=owner, repo=repo) + "/issues?state=open&per_page=100", headers=headers) | |
issues = response.json() | |
# Tüm sayfaları dolaşarak issue'ları al | |
while "next" in response.links: | |
next_url = response.links["next"]["url"] | |
response = requests.get(next_url, headers=headers) | |
issues.extend(response.json()) | |
# Her bir issue için yorum ekle | |
for issue in issues: | |
issue_number = issue["number"] | |
comment_url = base_url.format(owner=owner, repo=repo) + f"/issues/{issue_number}/comments" | |
user = issue["user"]["login"] | |
comment_text = f"{comment_body} @{user}" | |
# Yorumu gönder | |
comment_data = { | |
"body": comment_text | |
} | |
# print(comment_text) | |
response = requests.post(comment_url, headers=headers, data=json.dumps(comment_data)) | |
if response.status_code == 201: | |
print(f"Yorum eklendi: Issue #{issue_number}") | |
else: | |
print(response.status_code) | |
print(response.json()) | |
print(f"Yorum eklenirken hata oluştu: Issue #{issue_number}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment