From: MatthieuCoder Date: Sun, 22 Jan 2023 10:08:20 +0000 (+0400) Subject: change licence and add a 30% probability X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0a64a05da2c0edb0177a9b533e4174bc712d54b1;p=matthieu%2Fgru.git change licence and add a 30% probability --- diff --git a/LICENCE b/LICENCE index ad1989f..286ea8c 100644 --- a/LICENCE +++ b/LICENCE @@ -1,7 +1,7 @@ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 - Copyright (C) 2004 Sam Hocevar + Copyright (C) 2023 Pignolet Matthieu Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long diff --git a/autofeur_db/src/trie.rs b/autofeur_db/src/trie.rs index 8e8decc..047c7ec 100644 --- a/autofeur_db/src/trie.rs +++ b/autofeur_db/src/trie.rs @@ -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, } } diff --git a/autofeur_nova/src/index.mts b/autofeur_nova/src/index.mts index a5a2efa..6820d54 100644 --- a/autofeur_nova/src/index.mts +++ b/autofeur_nova/src/index.mts @@ -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) {} + } } );