Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 49f85b3

Browse files
authored
Merge pull request #215 from codeoverflow-org/sample/irc
Add IRC sample
2 parents 70314dd + 934bbe2 commit 49f85b3

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

samples/irc/extension/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { NodeCG } from "nodecg/types/server";
2+
import { requireService } from "nodecg-io-core";
3+
import { IRCServiceClient } from "nodecg-io-irc";
4+
5+
module.exports = function (nodecg: NodeCG) {
6+
nodecg.log.info("Sample bundle for irc started.");
7+
8+
const service = requireService<IRCServiceClient>(nodecg, "irc");
9+
service?.onAvailable((client) => {
10+
nodecg.log.info("IRC client has been updated.");
11+
client.join("#skate702"); // Change this channel, if you want to connect to a different channel.
12+
13+
client.addListener("message", (from, to, message) => {
14+
nodecg.log.info(from + " => " + to + ": " + message);
15+
});
16+
17+
client.addListener("error", function (message) {
18+
nodecg.log.info("error: ", message);
19+
});
20+
});
21+
22+
service?.onUnavailable(() => nodecg.log.info("IRC client has been unset."));
23+
};

samples/irc/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "irc",
3+
"version": "0.1.0",
4+
"private": true,
5+
"nodecg": {
6+
"compatibleRange": "^1.1.1",
7+
"bundleDependencies": {
8+
"nodecg-io-irc": "^0.1.0"
9+
}
10+
},
11+
"scripts": {
12+
"build": "tsc -b",
13+
"watch": "tsc -b -w",
14+
"clean": "tsc -b --clean"
15+
},
16+
"license": "MIT",
17+
"dependencies": {
18+
"@types/node": "^14.14.13",
19+
"nodecg": "^1.7.4",
20+
"nodecg-io-core": "^0.1.0",
21+
"nodecg-io-irc": "^0.1.0",
22+
"typescript": "^4.1.3"
23+
}
24+
}

samples/irc/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.common.json"
3+
}

0 commit comments

Comments
 (0)