1212from _utils import *
1313from discord import update_hook
1414
15-
1615async def batch_github_plugin_info (
17- info : P , tags : ETagsType , github_token = None , webhook_url : str = None
16+ info : P , tags : ETagsType , github_token = None , webhook_url : str | None = None
1817) -> P :
1918 try :
2019 headers = {"authorization" : f"token { github_token } " }
@@ -47,9 +46,10 @@ async def batch_github_plugin_info(
4746 info [release_date ] = latest_rel .get ("published_at" )
4847 if assets :
4948 info [url_download ] = assets [0 ]["browser_download_url" ]
50- await send_notification (
51- info , clean (latest_rel ["tag_name" ], "v" ), latest_rel , webhook_url
52- )
49+ if webhook_url :
50+ await send_notification (
51+ info , clean (latest_rel ["tag_name" ], "v" ), latest_rel , webhook_url
52+ )
5353 info [version ] = clean (latest_rel ["tag_name" ], "v" )
5454
5555 tags [info [id_name ]] = res .headers .get (etag , "" )
@@ -62,7 +62,7 @@ async def batch_github_plugin_info(
6262
6363
6464async def batch_plugin_infos (
65- plugin_infos : Ps , tags : ETagsType , github_token , webhook_url : str = None
65+ plugin_infos : Ps , tags : ETagsType , github_token , webhook_url : str | None = None
6666) -> Ps :
6767 return await tqdm .gather (
6868 * [
@@ -72,7 +72,7 @@ async def batch_plugin_infos(
7272 )
7373
7474
75- def remove_unused_etags (plugin_infos : Ps , etags : ETagsType ) -> ETagsType :
75+ def remove_unused_etags (plugin_infos : PluginsType , etags : ETagsType ) -> ETagsType :
7676 etags_updated = {}
7777 plugin_ids = [info .get ("ID" ) for info in plugin_infos ]
7878
@@ -90,16 +90,18 @@ def remove_unused_etags(plugin_infos: Ps, etags: ETagsType) -> ETagsType:
9090
9191
9292async def send_notification (
93- info : P , latest_ver , release , webhook_url : str = None
93+ info : PluginType , latest_ver , release , webhook_url : str | None = None
9494) -> None :
95+ if not webhook_url :
96+ return
97+
9598 if version_tuple (info [version ]) != version_tuple (latest_ver ):
9699 tqdm .write (f"Update detected: { info [plugin_name ]} { latest_ver } " )
97100 try :
98101 await update_hook (webhook_url , info , latest_ver , release )
99102 except Exception as e :
100103 tqdm .write (str (e ))
101104
102-
103105async def main ():
104106 webhook_url = None
105107 if len (argv ) > 1 :
0 commit comments