1
0
Quellcode durchsuchen

Adding AniList icon to AniList feed embed messages

Lucas Villeneuve vor 5 Jahren
Ursprung
Commit
b8d34b7243
3 geänderte Dateien mit 7 neuen und 6 gelöschten Zeilen
  1. 1 0
      myanimebot.example.conf
  2. 2 1
      src/globals.py
  3. 4 5
      src/myanimebot.py

+ 1 - 0
myanimebot.example.conf

@@ -27,5 +27,6 @@ prefix = !malbot
 
 # Bot icons
 iconMAL = https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png
+iconAniList = https://anilist.co/img/icons/android-chrome-512x512.png
 iconBot = http://myanimebot.pentou.eu/rsc/bot_avatar.jpg
 

+ 2 - 1
src/globals.py

@@ -52,7 +52,8 @@ timezone=pytz.timezone(CONFIG.get("timezone", "utc"))
 secondMax=CONFIG.getint("secondMax", 7200)
 token=CONFIG.get("token")
 prefix=CONFIG.get("prefix", "!malbot")
-iconMAL=CONFIG.get("iconMAL", "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png")
+MAL_ICON_URL=CONFIG.get("iconMAL", "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png")
+ANILIST_ICON_URL=CONFIG.get("iconAniList", "https://anilist.co/img/icons/android-chrome-512x512.png")
 iconBot=CONFIG.get("iconBot", "http://myanimebot.pentou.eu/rsc/bot_avatar.jpg")
 SERVICE_ANILIST="AniList"
 SERVICE_MAL="mal"

+ 4 - 5
src/myanimebot.py

@@ -48,21 +48,20 @@ def build_embed(user, item_title, item_link, item_description, pub_date, image,
 	if service == utils.Service.MAL:
 		service_name = 'MyAnimeList'
 		profile_url = "{}{}".format(globals.MAL_PROFILE_URL, user)
+		icon_url = globals.MAL_ICON_URL
 	elif service == utils.Service.ANILIST:
 		service_name = 'AniList'
 		profile_url = "{}{}".format(globals.ANILIST_PROFILE_URL, user)
+		icon_url = globals.ANILIST_ICON_URL
 	else:
 		raise NotImplementedError('Unknown service {}'.format(service))
 	description = "[{}]({})\n```{}```".format(utils.filter_name(item_title), item_link, item_description)
 	profile_url_label = "{}'s {}".format(user, service_name)
 
 	try:	
-		embed = discord.Embed(colour=0xEED000,
-								url=item_link,
-								description=description,
-								timestamp=pub_date.astimezone(pytz.timezone("utc")))
+		embed = discord.Embed(colour=0xEED000, url=item_link, description=description, timestamp=pub_date.astimezone(pytz.timezone("utc")))
 		embed.set_thumbnail(url=image)
-		embed.set_author(name=profile_url_label, url=profile_url, icon_url=globals.iconMAL)
+		embed.set_author(name=profile_url_label, url=profile_url, icon_url=icon_url)
 		embed.set_footer(text="MyAnimeBot", icon_url=globals.iconBot)
 		
 		return embed