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
|
||||
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
|
||||
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> {
|
||||
TrieNode {
|
||||
is_final,
|
||||
child_nodes: HashMap::new(),
|
||||
child_nodes: HashMap::with_capacity(256),
|
||||
child_count: 0,
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl<'a> TrieNode<'a> {
|
|||
pub fn new_root<'b>() -> TrieNode<'b> {
|
||||
TrieNode {
|
||||
is_final: false,
|
||||
child_nodes: HashMap::new(),
|
||||
child_nodes: HashMap::with_capacity(256),
|
||||
child_count: 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,21 +65,23 @@ emitter.on(
|
|||
async (message: GatewayMessageCreateDispatch["d"]) => {
|
||||
// we shall not repond to bots
|
||||
if (message.author.bot) return;
|
||||
try {
|
||||
// Get the completed word found by the db.
|
||||
let response = await completeWord(cutWord(message.content));
|
||||
if (Math.random() >= 0) {
|
||||
try {
|
||||
// Get the completed word found by the db.
|
||||
let response = await completeWord(cutWord(message.content));
|
||||
|
||||
// Ignore if there is no completion
|
||||
if (response || response === "") {
|
||||
// Respond to the message.
|
||||
await emitter.rest.post(Routes.channelMessages(message.channel_id), {
|
||||
body: {
|
||||
content: response,
|
||||
message_reference: { message_id: message.id },
|
||||
} as RESTPostAPIChannelMessageJSONBody,
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
// Ignore if there is no completion
|
||||
if (response || response === "") {
|
||||
// Respond to the message.
|
||||
await emitter.rest.post(Routes.channelMessages(message.channel_id), {
|
||||
body: {
|
||||
content: response,
|
||||
message_reference: { message_id: message.id },
|
||||
} as RESTPostAPIChannelMessageJSONBody,
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue