circumspect / White-Rabbit

A bot for running Alice is Missing on Discord. Server template: https://discord.new/SfcBdbyhGMmR
https://white-rabbit.readthedocs.io/
GNU Affero General Public License v3.0
43 stars 41 forks source link

MissingGameData after session #97

Closed Gabbalo closed 3 years ago

Gabbalo commented 3 years ago

Hi I got the ErrorMessage "MissingGameData" after our session while issuing the !pdf command. The server console does not show any error, the last message there is the "who-gets-which-clue-card"-message. Any idea how to reclaim that data? Or how to fix this for the next session?

circumspect commented 3 years ago

Hmm, this is most likely caused by the first message of the game not matching the message in the language.json file. When importing the data from the server, the bot checks for the first 20 characters of the (localized) starter message in each message in the group chat channel so that it knows where the first message of the game was. If this is the case, the easiest fix for now is to edit the starting message and replace the text with the starting message (which should be sent to Charlie's clues channel with the 90 minute card).

As for the code, fixing that would probably entail adding a fallback so that if it doesn't find a matching message it just uses the first message in the channel as the reference for the start of the game (the original reason for the check was so that the admin wouldn't have to delete message by hand if there were some accidental messages in the channel before the start of game). Let me know if the temporary solution works for you, and if so I'll try to fix it in the code sometime in the next week.

Gabbalo commented 3 years ago

I started the game (e.g. the bot) in fact about 4 minutes late, so some messages where already written in the chats. Thats why I had to write a "custom" message to start with - which of course did not match the localized message. I changed the message and now it seems to work - with a warning "WARNING: Unknown image found during export: debrief" and some font-type errors

/home/user/.local/lib/python3.9/site-packages/fpdf/ttfonts.py:831: UserWarning: missing glyph 389
  warnings.warn("missing glyph %s" % (originalGlyphIdx))
/home/user/.local/lib/python3.9/site-packages/fpdf/ttfonts.py:710: UserWarning: missing glyph 389
  warnings.warn("missing glyph %s" % (originalGlyphIdx))

I may be running an older version of the repo and I am currently trying to update it which seems to be somehow complicated. I deleted my own repo and forked the original again and as soon as I open it in GitHub for Windows, I have several changes pending - even tho I did not changed a thing.

2021-05-09 08_46_55-GitHub Desktop

As soon as I can figure it out, how to solve this, I also can update the german localization (the upload message).

circumspect commented 3 years ago

The warning about the unknown image is a debugging thing - it goes through each character's clues channels to find the appropriate clues and suspects/locations, but because the debrief card is also sent to Charlie and doesn't match any of those, the bot flags it. The font warnings can also be ignored, I'm not entirely sure what causes them but they won't affect the output.

The .kra files changing is my bad, it's most likely the result of me adding a .gitattributes file and not flagging them as binary files that shouldn't be changed. I'm not entirely sure why resources.py might have changed, maybe there were some CRLF line endings that got missed?

circumspect commented 3 years ago

Edit: the missing glyph warnings might be caused by one of the fonts not supporting non alphanumeric characters, it might work better with another font but I'm not sure

Gabbalo commented 3 years ago

The .kra files changing is my bad, it's most likely the result of me adding a .gitattributes file and not flagging them as binary files that shouldn't be changed. I'm not entirely sure why resources.py might have changed, maybe there were some CRLF line endings that got missed?

Yeah, probably a CRLF or something, I could not see any difference in the preview ... but I don't want to mess anything up :D There are strange things you can do to a code without getting noticed - at least by a human but for sure for a system ... try one of these little bastards ";" instead of ";" - and they are not the same ;) Anyways ... unless I am SURE what I am doing, I keep away from code for everyones sake. But at some time I need to figure out how to get emojis in the pdf, because they are really missed :( Alphanumeric characters - at least not the german ones like ä,ö, ü or ß - are a probleme here, they are printed just fine in the pdf. I'm not sure, how that is a fact for accents like á or something like that, we don't use them ^^

circumspect commented 3 years ago

Ah, for emojis you'll have to muck around with the FPDF library, I'm not even sure they're supported so I just removed them from the texts entirely when exporting. There's a fork as well with more features (https://github.com/PyFPDF/fpdf2), though I don't know if that would change anything with regard to emojis and I haven't tested it with the bot either. Feel free to test it out and see if you can make a simple PDF with some emojis though - if it works I'm more than happy to add them when I have time