55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
|
import time
|
||
|
import feedparser
|
||
|
import requests
|
||
|
|
||
|
# Bugzilla RSS feed URL
|
||
|
BUGZILLA_RSS_URL = "https://bugs.koozali.org/buglist.cgi?chfield=%5BBug%20creation%5D&chfieldfrom=7d&ctype=atom&title=Bugs%20reported%20in%20the%20last%207%20days"
|
||
|
# Updated Rocket.Chat webhook URL
|
||
|
ROCKET_CHAT_URL = "https://chat.koozali.org/hooks/677e97a73ddf8049989dbc8c/r9uiYpTRAXo3mkFKxHnoTwGCdtKpYaDemCpHArgz89knkwLo"
|
||
|
|
||
|
# Set to keep track of sent bug IDs
|
||
|
sent_bugs = set()
|
||
|
|
||
|
# Function to send message to Rocket.Chat
|
||
|
def send_to_rocket_chat(bug_title, bug_link, bug_id):
|
||
|
payload = {
|
||
|
"alias": "Bugzilla",
|
||
|
"text": f"Bug Report - ID: {bug_id}",
|
||
|
"attachments": [
|
||
|
{
|
||
|
"title": bug_title,
|
||
|
"title_link": bug_link,
|
||
|
"color": "#764FA5"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
response = requests.post(ROCKET_CHAT_URL, json=payload)
|
||
|
if response.status_code == 200:
|
||
|
print(f"Bug report sent successfully: {bug_title} (ID: {bug_id})")
|
||
|
else:
|
||
|
print(f"Failed to send bug report: {response.status_code} - {response.text}")
|
||
|
|
||
|
# Function to fetch and parse the Bugzilla RSS feed
|
||
|
def fetch_bugzilla_feed():
|
||
|
feed = feedparser.parse(BUGZILLA_RSS_URL)
|
||
|
return feed.entries
|
||
|
|
||
|
# Main polling loop
|
||
|
def main():
|
||
|
while True:
|
||
|
entries = fetch_bugzilla_feed()
|
||
|
|
||
|
for entry in entries:
|
||
|
bug_id = entry.id.split('=')[-1] # Extract the bug number from the URL
|
||
|
if bug_id not in sent_bugs:
|
||
|
title = entry.title.strip()
|
||
|
link = entry.link
|
||
|
# Send the bug title, link, and ID
|
||
|
send_to_rocket_chat(title, link, bug_id)
|
||
|
sent_bugs.add(bug_id) # Track the sent bug ID
|
||
|
|
||
|
# Wait for 1 minute before polling again
|
||
|
time.sleep(60)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|