1111def random_party_emoji ():
1212 return random .choice (party_time_emoji )
1313
14- def announce_release (app , release ):
14+ def announce_release (app , release , is_generated ):
1515 release_notes = release .release_notes
1616 if not release_notes :
1717 release_notes = "N/A"
@@ -35,9 +35,9 @@ def announce_release(app, release):
3535 }]
3636 }
3737
38- send_discord_webhook (request_data )
38+ send_discord_webhook (request_data , is_generated )
3939
40- def announce_new_app (app ):
40+ def announce_new_app (app , is_generated ):
4141 request_fields = [{
4242 "name" : "Name" ,
4343 "value" : app .title
@@ -70,11 +70,13 @@ def announce_new_app(app):
7070 "value" : app .website
7171 })
7272
73+ txt_type = app .type if not is_generated else "Generated Watchface"
74+
7375 request_data = {
7476 "embeds" : [{
75- "title" : f"New { str (app . type ).capitalize ()} Alert { random_party_emoji ()} " ,
77+ "title" : f"New { str (txt_type ).capitalize ()} Alert { random_party_emoji ()} " ,
7678 "url" : f"{ config ['APPSTORE_ROOT' ]} /application/{ app .id } " ,
77- "description" : f"There's a new { app . type } on the appstore!" ,
79+ "description" : f"There's a new { txt_type } on the appstore!" ,
7880 "thumbnail" : {
7981 "url" : generate_image_url (app .icon_large , 80 , 80 , True , True ),
8082 "height" : 80 ,
@@ -83,8 +85,8 @@ def announce_new_app(app):
8385 "fields" : request_fields
8486 }]
8587 }
86-
87- send_discord_webhook (request_data )
88+
89+ send_discord_webhook (request_data , is_generated )
8890
8991def audit_log (operation ):
9092 request_fields = [{
@@ -112,10 +114,15 @@ def audit_log(operation):
112114
113115 send_admin_discord_webhook (request_data )
114116
115- def send_discord_webhook (request_data ):
116- if config ['DISCORD_HOOK_URL' ] is not None :
117- headers = {'Content-Type' : 'application/json' }
118- requests .post (config ['DISCORD_HOOK_URL' ], data = json .dumps (request_data ), headers = headers )
117+ def send_discord_webhook (request_data , is_generated = False ):
118+ if not is_generated :
119+ if config ['DISCORD_HOOK_URL' ] is not None :
120+ headers = {'Content-Type' : 'application/json' }
121+ requests .post (config ['DISCORD_HOOK_URL' ], data = json .dumps (request_data ), headers = headers )
122+ else :
123+ if config ['DISCORD_GENERATED_HOOK_URL' ] is not None :
124+ headers = {'Content-Type' : 'application/json' }
125+ requests .post (config ['DISCORD_GENERATED_HOOK_URL' ], data = json .dumps (request_data ), headers = headers )
119126
120127def send_admin_discord_webhook (request_data ):
121128 if config ['DISCORD_ADMIN_HOOK_URL' ] is not None :
0 commit comments