Created
April 23, 2017 19:05
-
-
Save gamefreak/ddf43be459c8f079308f9e7b3422df94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from yapsy.IPlugin import IPlugin | |
import zipfile | |
import json | |
class ConversationsBackend(IPlugin): | |
pack = None | |
def build(self, pack): | |
self.pack = pack | |
print "[Conversations] Building zip..." | |
self.makeZip() | |
def makeZip(self): | |
outzip = zipfile.ZipFile(self.pack.output+"/"+self.pack.filename+"-conversations.zip", 'w') | |
aliases = {} | |
for emote in self.pack.emotelist: | |
try: | |
outzip.write(self.pack.path+"/"+emote.filename, emote.filename) | |
for shortcut in emote.shortcuts: | |
aliases[shortcut] = emote.filename | |
except OSError: | |
# The underlying emote file isn't found | |
# This throws varying errors, but are all OSError or subclasses | |
pass | |
outzip.writestr(self.pack.path+"/emoticons.json", json.dumps({"emotes": aliases})) | |
outzip.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment