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,15 +113,26 @@ 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
|
||||||
url = repo.url + r"/commits/" + repo.branch + ".atom"
|
if repo.url.startswith("https://github.com"):
|
||||||
response = await self.fetch_feed(url)
|
url = repo.url + r"/commits/" + repo.branch + ".atom"
|
||||||
try:
|
response = await self.fetch_feed(url)
|
||||||
commit = response.entries[0]["id"][33:]
|
try:
|
||||||
hash = "[" + commit + "](" + response.entries[0]["link"] + ")"
|
commit = response.entries[0]["id"][33:]
|
||||||
cn = response.entries[0]["title"] + " - " + response.entries[0]["author"]
|
hash = "[" + commit + "](" + response.entries[0]["link"] + ")"
|
||||||
image = response.entries[0]["media_thumbnail"][0]["url"].split("?")[0]
|
cn = response.entries[0]["title"] + " - " + response.entries[0]["author"]
|
||||||
except AttributeError:
|
image = response.entries[0]["media_thumbnail"][0]["url"].split("?")[0]
|
||||||
continue
|
except AttributeError:
|
||||||
|
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)
|
||||||
e.set_thumbnail(url=image)
|
if image is not None:
|
||||||
|
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