forked from blizzthewolf/SeaCogs
feat(updatechecker): added gitea/forgejo support
This commit is contained in:
parent
c2b2dcb8a0
commit
b4647a3c6b
1 changed files with 26 additions and 16 deletions
|
@ -37,7 +37,7 @@ import aiohttp
|
||||||
import discord
|
import discord
|
||||||
from redbot.cogs.downloader.repo_manager import Repo
|
from redbot.cogs.downloader.repo_manager import Repo
|
||||||
from redbot.core import Config, commands
|
from redbot.core import Config, commands
|
||||||
from redbot.core.utils.chat_formatting import humanize_list, inline
|
from redbot.core.utils.chat_formatting import box, humanize_list, inline
|
||||||
|
|
||||||
import feedparser
|
import feedparser
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ class UpdateChecker(commands.Cog):
|
||||||
repo = cog._repo_manager.get_repo(repo_name)
|
repo = cog._repo_manager.get_repo(repo_name)
|
||||||
if not repo:
|
if not repo:
|
||||||
continue
|
continue
|
||||||
|
if repo.url.startswith("https://github.com"):
|
||||||
url = repo.url + r"/commits/" + repo.branch + ".atom"
|
url = repo.url + r"/commits/" + repo.branch + ".atom"
|
||||||
response = await self.fetch_feed(url)
|
response = await self.fetch_feed(url)
|
||||||
try:
|
try:
|
||||||
|
@ -122,6 +123,16 @@ class UpdateChecker(commands.Cog):
|
||||||
image = response.entries[0]["media_thumbnail"][0]["url"].split("?")[0]
|
image = response.entries[0]["media_thumbnail"][0]["url"].split("?")[0]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
url = repo.url + "rss/branch/" + repo.branch
|
||||||
|
response = await self.fetch_feed(url)
|
||||||
|
try:
|
||||||
|
commit = response.entries[0]["id"][33:]
|
||||||
|
hash = "[" + commit + "](" + response.entries[0]["link"] + ")"
|
||||||
|
cn = response.entries[0]["title"] + " - " + response.entries[0]["author"]
|
||||||
|
image = None
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
saving_dict[repo_name] = commit
|
saving_dict[repo_name] = commit
|
||||||
if whitelist:
|
if whitelist:
|
||||||
if repo_name not in whitelist:
|
if repo_name not in whitelist:
|
||||||
|
@ -147,18 +158,17 @@ class UpdateChecker(commands.Cog):
|
||||||
e.add_field(name="Branch", value=repo.branch)
|
e.add_field(name="Branch", value=repo.branch)
|
||||||
e.add_field(name="Commit", value=cn)
|
e.add_field(name="Commit", value=cn)
|
||||||
e.add_field(name="Hash", value=hash)
|
e.add_field(name="Hash", value=hash)
|
||||||
|
if image is not None:
|
||||||
e.set_thumbnail(url=image)
|
e.set_thumbnail(url=image)
|
||||||
else:
|
else:
|
||||||
e = (
|
e = box(
|
||||||
"```css\n"
|
|
||||||
"[Update Checker]"
|
"[Update Checker]"
|
||||||
"``````css\n"
|
|
||||||
f" Repo: {repo.name}\n"
|
f" Repo: {repo.name}\n"
|
||||||
f" URL: {repo.url}\n"
|
f" URL: {repo.url}\n"
|
||||||
f" Commit: {cn}\n"
|
f" Commit: {cn}\n"
|
||||||
f" Hash: {commit}\n"
|
f" Hash: {commit}\n"
|
||||||
f" Time: {datetime.utcnow()}"
|
f" Time: {datetime.utcnow()}",
|
||||||
"```"
|
'css'
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
if use_embed:
|
if use_embed:
|
||||||
|
|
Loading…
Reference in a new issue