OnionSproutsBot issueshttps://gitlab.torproject.org/tpo/anti-censorship/gettor-project/OnionSproutsBot/-/issues2023-01-24T20:39:20Zhttps://gitlab.torproject.org/tpo/anti-censorship/gettor-project/OnionSproutsBot/-/issues/34add dates to log files again2023-01-24T20:39:20Zn0tooseadd dates to log files againAfter lots of research and reading through relatively undocumented source code, I finally removed the `logging` module. Unfortunately, its successor, `aiologger`, doesn't really work in a backwards-compatible manner and using it has intr...After lots of research and reading through relatively undocumented source code, I finally removed the `logging` module. Unfortunately, its successor, `aiologger`, doesn't really work in a backwards-compatible manner and using it has introduced a couple of small, yet still annoying, regressions. One of them is the fact that you cannot really control the way messages are formatted when you are "streaming" the output of the bot to a file.
There are two possibilities:
1. Do not use `datefmt` in the handlers of the logger, include `datefmt` in the text of the message that is to be logged itself.
2. Implement `formatting` (which already exists for stream handlers) to file handlers as well, or find another way to emulate that behavior. This would preferably happen upstream. This will require some work/external communication with the developers of aiologger.n0toosen0toosehttps://gitlab.torproject.org/tpo/anti-censorship/gettor-project/OnionSproutsBot/-/issues/2How should locales be dealt with?2022-03-08T13:26:56Zn0tooseHow should locales be dealt with?I finally got the bot to work using the new library that I had to use. It allows me to use callbacks, which help me with asking for the user's platform, then generating a list of locales that are available to that specific platform, with...I finally got the bot to work using the new library that I had to use. It allows me to use callbacks, which help me with asking for the user's platform, then generating a list of locales that are available to that specific platform, without the user having to send a text message that looks like "`English (USA), Linux (32-bit)`.
Here's a screenshot:
![image](/uploads/39a668707bddd16828b63f3785beb292/image.png)
I used the `InlineKeyboardButton`s to add the locales, however, they don't all fit in one row.
## Scenarios
Do I:
- Split the locales in different rows?
Problem: In order to be user friendly, you'd have to use the names of the locales that are readable by human beings. In the previous screenshot, more than 5 locales fit in one row, because each locale consisted of 2 characters. I doubt that this is going to work when you have locales that range from "Dutch (Netherlands) a
- Replace locale names with flags?
Problem: Stateless populations, niche locales, countries with more than two official languages or countries with large foreign-speaking populations (e.g. Malta, Canada, etc.).
- Use the user's preferred language on Telegram and just ask for their preferred operating system?
This seems by far the simplest solution to me and simplifies UX, although I haven't sought after implementing it. It simplifies deciding for the language that the bot will communicate in with the user.
Problem: Although it's a bit easier to maintain, it limits available options and forces the user to disclose that information to Telegram, which technically already has access to this information anyways. However, Telegram can be used as a means of establishing a data transfer with encryption (because of "Secret Chats", which are now possible but haven't been explored yet). Also, there may be a locale that could be available on Telegram but not to the bot/the requested program, and vice versa.
- Have the user choose an operating system, and then using a "ReplyKeyboardMarkup" to provide a scrollable menu of options with locales.
Here's how a ReplyKeyboardMarkup would look like:
![image](/uploads/d779d25bc9efd4b2d8696e9e1654a6c5/image.png)
Problem: Increases complexity, may require dealing with a database that will store metadata about the end user, makes hosting more difficult to other people. When the user clicks on a button in a "ReplyKeyboardMarkup", they have to send a text message, which the bot will have to process. That will break things if the user sends a message with just the locale, without having issued their preferred operating system, unless if the bot generates a menu consisting of keys that looks like `English (USA), Linux (32-bit)`.
## Goal
The goal is to:
- **not** store user information and data.
- **accommodate** as many people as possible regardless of their locale
If a `ReplyKeyboardMarkup` (the series of buttons on top of the keyboard) is to be used, it can only be used once and in the beginning. When the user makes a decision, the bot dynamically generates a new prompt with a new set of buttons, which also stores the previous decision of the user with the help of `InlineKeyboardMarkup`'s (the buttons under text messages from the bot).