]> git.puffer.fish Git - matthieu/gru.git/commitdiff
change licence and add a 30% probability
authorMatthieuCoder <matthieu@matthieu-dev.xyz>
Sun, 22 Jan 2023 10:08:20 +0000 (14:08 +0400)
committerMatthieuCoder <matthieu@matthieu-dev.xyz>
Sun, 22 Jan 2023 10:08:20 +0000 (14:08 +0400)
LICENCE
autofeur_db/src/trie.rs
autofeur_nova/src/index.mts

diff --git a/LICENCE b/LICENCE
index ad1989f13dd910b4a4b276244f7c478c6aa5b414..286ea8c53fd9a2c91bce43c76c683922fc8dc85f 100644 (file)
--- 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 <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 
index 8e8decc4109c314cb2e14d2fc0b1bc7224c799c4..047c7ec8fbedff8376d950333a50610cae91fc23 100644 (file)
@@ -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,
         }
     }
index a5a2efae37d31858ea7278720eda38e4107511f2..6820d54f5fa90288a4218e32a9281db3178c1dee 100644 (file)
@@ -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) {}
+    }
   }
 );