-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
always load all scripts in type/, command/ and handler/ #83
base: main
Are you sure you want to change the base?
Changes from all commits
9285a61
4067256
76dc200
f9fd68d
939a045
b56f44d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,29 +24,27 @@ import StructTypes | |
|
||
const COMMAND_PREFIX = get(ENV, "HOJBOT_COMMAND_PREFIX", ",") | ||
|
||
function loadplugins() | ||
includejlfiles("type/") | ||
includejlfiles("command/") | ||
includejlfiles("handler/") | ||
end | ||
|
||
function includejlfiles(dir) | ||
wd = walkdir(joinpath(@__DIR__, dir)) | ||
commands = first(wd) | ||
close(wd) | ||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it only works with single level, it's simpler to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, that’s why I suggested that. The code would be simpler since you don’t need to deal with the tuple from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but on the other hand I only need the files (not the directories) and walkdir already sorts by type of element. |
||
foreach(commands[3]) do command | ||
endswith(command, ".jl") && include(joinpath(commands[1], command)) | ||
end | ||
end | ||
|
||
include("constants.jl") | ||
include("dispatcher.jl") | ||
include("util.jl") | ||
include("discord.jl") | ||
include("main.jl") | ||
|
||
include("command/tz.jl") | ||
include("command/j.jl") | ||
include("command/gm.jl") | ||
include("command/react.jl") | ||
include("command/src.jl") | ||
|
||
include("handler/reaction.jl") | ||
include("handler/whistle.jl") | ||
|
||
include("type/mod.jl") | ||
include("handler/mod.jl") | ||
|
||
include("type/discourse.jl") | ||
include("command/discourse.jl") | ||
include("handler/discourse.jl") | ||
|
||
include("type/ig.jl") | ||
include("command/ig.jl") | ||
loadplugins() | ||
|
||
end # module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use underscore to separate words in function names? We try to follow the BlueStyle.
https://github.com/invenia/BlueStyle#function-naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But Julia itself suggests to use underscores only if the name is otherwise unreadable: https://docs.julialang.org/en/v1/manual/style-guide/#Use-naming-conventions-consistent-with-Julia-base/
:/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm aware of that. But coding style standard is made for a reason. The BlueStyle is quite widely used in the industry, and it has a good balance of consistency that tends to work well for larger projects.
RE: naming convention, the standard Julia recommendation is too loose in my humble opinion-- when does one decide when the smashed-together name is starting to become unreadable? It's subjective.