J-Rios / TLG_JoinCaptchaBot

Telegram Bot to verify if users joining a group are human. The Bot sends an image captcha for each new user and kicks any of them who can't solve the captcha in a specified time.
GNU General Public License v3.0
520 stars 217 forks source link

[Bug] Docker build Bot fails if INIT_LANG is set to an invalid value #14

Closed marcopaganini closed 4 years ago

marcopaganini commented 4 years ago

Setting CONST.INIT_LANG to an invalid value prevents the Bot from initializing properly, without any relevant error messages logged. The bot will run, but not respond to any commands.

This is a particularly easy hole to fall in, since the /language command expects the language to be specified in lowercase (E.g, "en") but for CONFIG.INIT_LANG, the language needs to be specified in upper case (E.g. "EN"). A simple case mismatch is enough to trigger the problem.

J-Rios commented 4 years ago

The problem doesn't exists in /language command, becuase it forces to uppercase the provided language (see this line).

So the problem just exists in Docker build due the new possibility to set a default initial language different than english... It can be fixed in two ways:

If we go A, the build process can stop and say to the user that he has provided an invalid argument and shows valids languages. However, this way means that we needs to add the supported languages list into the makefile and anytime a new language support is added, the Makefile needs to be modified to include it into the array.

If we go B, we can safe handle thet invalid provided language, but there is no way to tell the user that he has build the docker container with an invalid language.

J-Rios commented 4 years ago

So I decided to go A... Now there is a safe check in docker Makefile to verify that provided default Bot language is valid.

Issue solved, going to close it, feel free to re-open it again if there something that I have miss.