nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: TheOdinProject/odin-bot-v2
Pull request #79 (2021-01-06 13:14:59)

note command
Adds the command `/note` or `/notes` that prints the link to the thoughts on note taking.
These thoughts are collected from TOP discord server I believe, and someone has made it as a google document.

https://docs.google.com/document/d/1fas8xwMRi4GVrnCtp9U5OL7Y9QB6v5H_Wx19m4UQwgI/edit

I have seen a lot of people asking about note taking, so I thought this could be useful.


Patch:
diff --git a/botCommands/notes.js b/botCommands/notes.js
new file mode 100644
index 0000000..85591a3
--- /dev/null
+++ b/botCommands/notes.js
@@ -0,0 +1,12 @@
+const { registerBotCommand } = require("../botEngine.js");
+
+const command = {
+  regex: /(?<!\S)\/notes(?!\S)/,
+  cb: () => { 
+    return `To note, or not to note, that is the question. Please read this: https://discord.com/channels/505093832157691914/505093832157691916/768161823366578176`
+  },
+};
+
+registerBotCommand(command.regex, command.cb);
+
+module.exports = command;


Test patch:
diff --git a/botCommands/__snapshots__/notes.test.js.snap b/botCommands/__snapshots__/notes.test.js.snap
new file mode 100644
index 0000000..d9b8377
--- /dev/null
+++ b/botCommands/__snapshots__/notes.test.js.snap
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`/notes callback returns correct output 1`] = `"To note, or not to note, that is the question. Please read this: https://discord.com/channels/505093832157691914/505093832157691916/768161823366578176"`;
diff --git a/botCommands/notes.test.js b/botCommands/notes.test.js
new file mode 100644
index 0000000..65f9218
--- /dev/null
+++ b/botCommands/notes.test.js
@@ -0,0 +1,52 @@
+const command = require('./notes')
+
+describe('/notes', () => {
+  describe('regex', () => {
+    it.each([
+      ['/notes'],
+      [' /notes'],
+      ['/notes @odin-bot'],
+      ['@odin-bot /notes'],
+    ])('correct strings trigger the callback', (string) => {
+      expect(command.regex.test(string)).toBeTruthy()
+    })
+    
+    it.each([
+     ["ntoes"],
+     ["notes"],
+     ["noets"],
+     ["/noets"],
+     ["/ntoes"],
+     ["/ notes"],
+     ["/anotes"]
+    ])("'%s' does not trigger the callback", (string) => {
+      expect(command.regex.test(string)).toBeFalsy()
+    })
+
+    it.each([
+      ['Check this out! /notes'],
+      ['Don\'t worry about /notes'],
+      ['Hey @odin-bot, /notes'],
+      ['/@odin-bot ^ /me /notes /tests$*']
+    ])("'%s' - command can be anywhere in the string", (string) => {
+      expect(command.regex.test(string)).toBeTruthy()
+    })
+
+    it.each([
+      ['@user/notes'],
+      ['it\'s about/notes'],
+      ['/notesanillusion'],
+      ['/notes/'],
+      ['/notes*'],
+      ['/notes...']
+    ])("'%s' - command should be its own word/group - no leading or trailing characters", (string) => {
+      expect(command.regex.test(string)).toBeFalsy()
+    })
+  })
+
+  describe('callback', () => {
+    it('returns correct output', () => {
+      expect(command.cb()).toMatchSnapshot()
+    })
+  })
+})