refactor: only capitalize initial for globals
This commit is contained in:
parent
4e64bc6ac4
commit
164ccd3a7f
@ -21,4 +21,4 @@ $ cargo build --release
|
|||||||
$ # ./target/release/errornowatcher
|
$ # ./target/release/errornowatcher
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure the `SERVER` and `USERNAME` globals are defined in `errornowatcher.lua` before starting the bot.
|
Make sure the `Server` and `Username` globals are defined in `errornowatcher.lua` before starting the bot.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
SERVER = "localhost"
|
Server = "localhost"
|
||||||
USERNAME = "ErrorNoWatcher"
|
Username = "ErrorNoWatcher"
|
||||||
OWNERS = { "ErrorNoInternet" }
|
Owners = { "ErrorNoInternet" }
|
||||||
|
|
||||||
for _, module in
|
for _, module in
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
let formatted_message = message.message();
|
let formatted_message = message.message();
|
||||||
info!("{}", formatted_message.to_ansi());
|
info!("{}", formatted_message.to_ansi());
|
||||||
|
|
||||||
let owners = globals.get::<Vec<String>>("OWNERS")?;
|
let owners = globals.get::<Vec<String>>("Owners")?;
|
||||||
if message.is_whisper()
|
if message.is_whisper()
|
||||||
&& let (Some(sender), content) = message.split_sender_and_content()
|
&& let (Some(sender), content) = message.split_sender_and_content()
|
||||||
&& owners.contains(&sender)
|
&& owners.contains(&sender)
|
||||||
|
@ -40,11 +40,11 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
let server = globals
|
let server = globals
|
||||||
.get::<String>("SERVER")
|
.get::<String>("Server")
|
||||||
.expect("SERVER should be in lua globals");
|
.expect("Server should be in lua globals");
|
||||||
let username = globals
|
let username = globals
|
||||||
.get::<String>("USERNAME")
|
.get::<String>("Username")
|
||||||
.expect("USERNAME should be in lua globals");
|
.expect("Username should be in lua globals");
|
||||||
|
|
||||||
globals.set("script_path", script_path)?;
|
globals.set("script_path", script_path)?;
|
||||||
lua::register_functions(&lua, &globals)?;
|
lua::register_functions(&lua, &globals)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user