change licence and add a 30% probability
This commit is contained in:
parent
9f798c57f8
commit
0a64a05da2
2
LICENCE
2
LICENCE
|
@ -1,7 +1,7 @@
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
Version 2, December 2004
|
Version 2, December 2004
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (C) 2023 Pignolet Matthieu <matthieu@matthieu-dev.xyz>
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Everyone is permitted to copy and distribute verbatim or modified
|
||||||
copies of this license document, and changing it is allowed as long
|
copies of this license document, and changing it is allowed as long
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl<'a> TrieNode<'a> {
|
||||||
pub fn new<'b>(is_final: bool) -> TrieNode<'b> {
|
pub fn new<'b>(is_final: bool) -> TrieNode<'b> {
|
||||||
TrieNode {
|
TrieNode {
|
||||||
is_final,
|
is_final,
|
||||||
child_nodes: HashMap::new(),
|
child_nodes: HashMap::with_capacity(256),
|
||||||
child_count: 0,
|
child_count: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ impl<'a> TrieNode<'a> {
|
||||||
pub fn new_root<'b>() -> TrieNode<'b> {
|
pub fn new_root<'b>() -> TrieNode<'b> {
|
||||||
TrieNode {
|
TrieNode {
|
||||||
is_final: false,
|
is_final: false,
|
||||||
child_nodes: HashMap::new(),
|
child_nodes: HashMap::with_capacity(256),
|
||||||
child_count: 0,
|
child_count: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,21 +65,23 @@ emitter.on(
|
||||||
async (message: GatewayMessageCreateDispatch["d"]) => {
|
async (message: GatewayMessageCreateDispatch["d"]) => {
|
||||||
// we shall not repond to bots
|
// we shall not repond to bots
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
try {
|
if (Math.random() >= 0) {
|
||||||
// Get the completed word found by the db.
|
try {
|
||||||
let response = await completeWord(cutWord(message.content));
|
// Get the completed word found by the db.
|
||||||
|
let response = await completeWord(cutWord(message.content));
|
||||||
|
|
||||||
// Ignore if there is no completion
|
// Ignore if there is no completion
|
||||||
if (response || response === "") {
|
if (response || response === "") {
|
||||||
// Respond to the message.
|
// Respond to the message.
|
||||||
await emitter.rest.post(Routes.channelMessages(message.channel_id), {
|
await emitter.rest.post(Routes.channelMessages(message.channel_id), {
|
||||||
body: {
|
body: {
|
||||||
content: response,
|
content: response,
|
||||||
message_reference: { message_id: message.id },
|
message_reference: { message_id: message.id },
|
||||||
} as RESTPostAPIChannelMessageJSONBody,
|
} as RESTPostAPIChannelMessageJSONBody,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue