English
Web appOpen in Telegram
BBot Development

Bot Development

@BotDevelopment · group · Tech · indexed since 2026-06-30
1 009members
6 144messages in the index
Whole thread · 1 reply →
D
Dusk 💛 💜Yeah, you may want to serialize that in the future
In the future, I would do it as described above, probably put it in a real database. I figure in this case, since I only really have one use for it, being able to look up IDs by username is more elegant than looking up usernames by ID, and there's never an urgent need to kick someone who hasn't posted in a while.
D
You should ideally when requiring things do local module = require('module'). Keeps it per file and namespaced
D
E.g. local a = foo; local b = function (potato) do salad end; return {a = a, b = b, c = 'lua'}
D
I don't localize them because 1) they're all needed by the main script so there's never a time they would not need to exist 2) i don't necessary require what I need in any given file
D
The assertions in bindings.lua are a recent change to make it more sensible to use that file without otouto.
  1. D
    and the requirements in utilities.lua exist because I constantly load that file in a shell without the main bot script
Whole thread · 1 reply →
D
What do you mean by both of those sentences?
D
Sorry. You have HTTPS = blah at the top of bot.lua. You then say HTTPS = blah again in utilities.lua. Because that file is loaded and ran at the point it's called and HTTPS is global in both places, you now have overwritten the original bot.lua HTTPS variable. This can cause problems with some libraries that keep state throughout a file.
D
It overwrites what HTTPS points with the same thing that HTTPS already points to. If I remember correctly, require differs from dofile in that require checks if the file has already been loaded, and if it has, uses that.
D
Maybe I'm not grasping what you mean, though, so correct me, but the way I see it, as long as the module pointed to is the same, this has no potential for harm.
D
Also require paths. I don't know. I guess it's fine, but might as well save the overwrite and not pollute the global namespace
D
Would localizing them in bot.lua keep them working when a plugin uses one?
D
Or would it make you happy if I changed the requirements in utilities.lua to HTTP = HTTP or require('socket.http')? :b
D
I guess I'm mostly worried about global pollution. Now that I think about it, the require keeps it from being actually overwritten in the dofile. So it's up to you. I think locals are cleaner, and prevent you from feeling pain if somewhere in a plugin you use JSON as a variable name. I imagine you shouting cased them to make them not collide, but locals do that too.
D
half-assedly following the "SHOUT DEFINITIONS" principle

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count