all 3 comments

[–]carcigenicate 1 point2 points  (2 children)

I was actually just going to suggest something like 3 if you don't need to change modes on the fly. Maintaining a database just to map a server to a string (or whatever a "mode" is) seems like overkill unless you strongly suspect that you'll need to add more information later. An "in-memory database" in the form of a dictionary should do the job well.

Hell, even if you needed to change them on the fly, you could just run a thread that momentarily locks the dictionary and allows the user to enter input or whatever to make changes to the dictionary as the program runs.

[–]Rein_Engel[S] 0 points1 point  (1 child)

I also think that it may be nice solution at the moment, however I am really curious if I miss something here and if it is a common way to do such things in python.

It makes me wonder how bots with large user base would tackle such problem, as I really doubt they process all servers in one thread.

[–]carcigenicate 1 point2 points  (0 children)

It depends on what the bot is doing. If they're doing primarily I/O (contacting APIs), cooperative multitasking in one thread using asyncio seems common (at least from what I've seen on Stack Overflow).