Selaa lähdekoodia

Improve Emoji Support (again)

Alex Taber 6 vuotta sitten
vanhempi
commit
e37ec7241b
1 muutettua tiedostoa jossa 2 lisäystä ja 8 poistoa
  1. 2
    8
      app.py

+ 2
- 8
app.py Näytä tiedosto

36
 message_delete_queue = []
36
 message_delete_queue = []
37
 
37
 
38
 def prepare_matrix_content(message):
38
 def prepare_matrix_content(message):
39
-	reg = re.match(r"^<a?:\w+:\d*>$", message.content)
39
+	reg = re.match(r"^<a?:\w+:(\d+)>$", message.content)
40
 
40
 
41
 	if reg:
41
 	if reg:
42
-		try:
43
-			return emoji_urls[message.content]
44
-		except:
45
-			pass
42
+		return "https://cdn.discordapp.com/emojis/{}.png?size=32".format(reg.group(1))
46
 
43
 
47
 	attachments = "\n".join([x.url for x in message.attachments])
44
 	attachments = "\n".join([x.url for x in message.attachments])
48
 	content = message.clean_content + ("\n" + attachments if attachments != "" else "")
45
 	content = message.clean_content + ("\n" + attachments if attachments != "" else "")
52
 guild = None
49
 guild = None
53
 channel = None
50
 channel = None
54
 emojis = {}
51
 emojis = {}
55
-emoji_urls = {}
56
 
52
 
57
 @discord_client.event
53
 @discord_client.event
58
 async def on_ready():
54
 async def on_ready():
65
 	for emoji in guild.emojis:
61
 	for emoji in guild.emojis:
66
 		if not emoji.animated:
62
 		if not emoji.animated:
67
 			emojis[":{}:".format(emoji.name)] = "<:{}:{}>".format(emoji.name, emoji.id)
63
 			emojis[":{}:".format(emoji.name)] = "<:{}:{}>".format(emoji.name, emoji.id)
68
-			emoji_urls["<:{}:{}>".format(emoji.name, emoji.id)] = emoji.url + "?size=32"
69
 		else:
64
 		else:
70
 			emojis[":{}:".format(emoji.name)] = "<a:{}:{}>".format(emoji.name, emoji.id)
65
 			emojis[":{}:".format(emoji.name)] = "<a:{}:{}>".format(emoji.name, emoji.id)
71
-			emoji_urls["<a:{}:{}>".format(emoji.name, emoji.id)] = emoji.url + "?size=32"
72
 
66
 
73
 @discord_client.event
67
 @discord_client.event
74
 async def on_message(message):
68
 async def on_message(message):