The wiki details on apichat buttons might be important here as you may have to sanitize a bunch of symbols for recursive tables to take the gif syntax, I think there might be a required line break in there that has to be escaped but I honestly don't remember, I know apichat buttons for macros need to be heavily sanitized for recursive tables. And they are basically the same syntax.