Add in Wiki to rocket and edit log path for bugzilla

This commit is contained in:
root
2025-02-27 09:05:33 +00:00
parent d7f2b71533
commit 712c80d113
3 changed files with 443 additions and 55 deletions

View File

@@ -4,6 +4,37 @@ import requests
import sqlite3
import logging
import os
import requests
from bs4 import BeautifulSoup
def join_lines_with_newline(lines):
return "\n".join(lines)
def extract_changelog_top(koji_link):
response = requests.get(koji_link)
soup = BeautifulSoup(response.text, 'html.parser')
changelog_td = soup.find('td', class_='changelog')
if changelog_td:
changelog_text = changelog_td.get_text(strip=False)
lines = changelog_text.split('\n')
result = []
seen = set()
for line in lines:
stripped_line = line.strip()
if not stripped_line:
if result: # Stop at the first blank line after content
break
continue
if stripped_line not in seen:
seen.add(stripped_line)
if not result or stripped_line.startswith('-'):
result.append(stripped_line)
return join_lines_with_newline(result)
else:
return []
# Koji RSS feed URL
KOJI_RSS_URL = "http://koji.koozali.org/koji/recentbuilds?feed=rss"
@@ -47,10 +78,10 @@ def mark_build_as_sent(build_id):
conn.close()
# Function to send message to Rocket.Chat
def send_to_rocket_chat(build_title, build_link, build_id):
def send_to_rocket_chat(build_title, build_link, build_id,changelog):
payload = {
"alias": "Koji",
"text": f"Build Notification - ID: {build_id}",
"text": f"Build Notification - ID: {build_id}\n{changelog}",
"attachments": [
{
"title": build_title,
@@ -95,9 +126,12 @@ def main():
build_link = entry.link
# Extracting the build ID from the title
build_id = build_title.split(':')[1].split(',')[0].strip() # Extract the relevant part from the title
changelog = extract_changelog_top(entry.link)
# print(f"{entry.link}\n{changelog}")
# quit(1)
if not has_build_been_sent(build_id): # Check if the build has been sent
send_to_rocket_chat(build_title, build_link, build_id)
send_to_rocket_chat(build_title, build_link, build_id,changelog)
mark_build_as_sent(build_id) # Mark the build ID as sent
# Wait for 1 minute before polling again