windsor-bot 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/poker/README.txt +6 -0
- package/assets/poker/club.svg +11 -0
- package/assets/poker/diamond.svg +8 -0
- package/assets/poker/heart.svg +9 -0
- package/assets/poker/spade.svg +9 -0
- package/dist/bot.js +109 -16
- package/dist/commands/index.js +2 -0
- package/dist/commands/poker.js +139 -0
- package/dist/index.js +9 -17
- package/dist/printing/index.js +39 -13
- package/dist/reactions.js +2 -1
- package/dist/server.js +52 -0
- package/dist/tests/config.test.js +8 -1
- package/dist/tests/poker.test.js +12 -0
- package/dist/tests/urls.test.js +11 -1
- package/dist/web/app.bundle.js +42 -2
- package/dist/web/app.js +41 -1
- package/package.json +2 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { mkdtemp, rm } from 'fs/promises';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
1
3
|
import { test } from 'node:test';
|
|
2
4
|
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
5
|
+
const configDir = await mkdtemp(`${tmpdir()}/windsor-config-test-`);
|
|
6
|
+
process.env['WINDSOR_CONFIG_PATH'] = `${configDir}/windsor.config.json`;
|
|
7
|
+
const { reconcileChannels, getCurrentConfig, updateConfig, hashPassword } = await import('../config.js');
|
|
8
|
+
test.after(async () => {
|
|
9
|
+
await rm(configDir, { recursive: true, force: true });
|
|
10
|
+
});
|
|
4
11
|
// Setup: initialize config with some channel mappings
|
|
5
12
|
async function withChannels(mappings, fn) {
|
|
6
13
|
const original = getCurrentConfig().channels;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { dealPokerHand } from '../commands/poker.js';
|
|
4
|
+
test('deals five board cards and four two-card hands without duplicates', () => {
|
|
5
|
+
const deal = dealPokerHand(() => 0.5);
|
|
6
|
+
const cards = [...deal.board, ...deal.hands.flat()];
|
|
7
|
+
const keys = cards.map(card => `${card.rank}${card.suit}`);
|
|
8
|
+
assert.equal(deal.board.length, 5);
|
|
9
|
+
assert.equal(deal.hands.length, 4);
|
|
10
|
+
assert.equal(cards.length, 13);
|
|
11
|
+
assert.equal(new Set(keys).size, cards.length);
|
|
12
|
+
});
|
package/dist/tests/urls.test.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { test } from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
|
-
import { extractUrls, stripUrls, replaceUrlsInText } from '../bot.js';
|
|
3
|
+
import { extractUrls, parseCommand, stripUrls, replaceUrlsInText } from '../bot.js';
|
|
4
|
+
test('parses commands with or without a space after the prefix', () => {
|
|
5
|
+
assert.deepEqual(parseCommand('!command'), { name: 'command', args: '' });
|
|
6
|
+
assert.deepEqual(parseCommand('! command'), { name: 'command', args: '' });
|
|
7
|
+
});
|
|
8
|
+
test('parses command arguments after optional prefix whitespace', () => {
|
|
9
|
+
assert.deepEqual(parseCommand('! command first second'), {
|
|
10
|
+
name: 'command',
|
|
11
|
+
args: 'first second',
|
|
12
|
+
});
|
|
13
|
+
});
|
|
4
14
|
test('extracts a single URL', () => {
|
|
5
15
|
const urls = extractUrls('Check this out https://example.com for more info');
|
|
6
16
|
assert.deepEqual(urls, ['https://example.com']);
|