rmtrollbot 3.2.2 → 4.1.0
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/README.md +25 -6
- package/index.mts +34 -5
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Reversed Meow TrollBot
|
|
2
|
-
[](https://packagequality.com/#?package=rmtrollbot)
|
|
1
|
+
# 
|
|
2
|
+
[](https://packagequality.com/#?package=rmtrollbot)[NPM Dependency Tree](https://npm.anvaka.com/#/view/2d/rmtrollbot)
|
|
3
3
|
# About
|
|
4
|
-
A package making the producing of rmtrollbox bots easier.<br>
|
|
4
|
+
A package making the producing of [rmtrollbox](https://trollbox.fun) bots easier.<br>
|
|
5
5
|
To start a bot, you must start a new TrollBot element.
|
|
6
6
|
```ts
|
|
7
7
|
let bot = new TrollBot("clanker", "gray")
|
|
@@ -37,7 +37,7 @@ bot.changeColor("#272822") // NICE TRY!!
|
|
|
37
37
|
```
|
|
38
38
|
## New for v2.0.0!
|
|
39
39
|
All types are now moved to [`rmtrollbot-types`](https://www.npmjs.com/package/rmtrollbot-types).
|
|
40
|
-
|
|
40
|
+
### New for v2.1.0!
|
|
41
41
|
Tags are now supported!
|
|
42
42
|
```ts
|
|
43
43
|
let bot = new TrollBot("clankah", "#BFBFBF", "bot" /* Defaults to "bot" */)
|
|
@@ -74,13 +74,29 @@ bot.lastMessageID((id)=>{
|
|
|
74
74
|
bot.editByID(id, "awh... you missed it!")
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
|
-
|
|
77
|
+
### New for v3.1.0!
|
|
78
78
|
Dang, these updates are comming FAST!<br>
|
|
79
79
|
Now, rmtrollbot uses [`ora`](https://www.npmjs.com/package/ora) when initializing a bot!<br>
|
|
80
80
|
Send any issues/suggestions for this package [here](https://github.com/Agsgt2/rmtrollbot-issues)!
|
|
81
|
-
|
|
81
|
+
### New for v3.2.0!
|
|
82
82
|
UH OH!!! UPDATE OVERFLOW!!!!<br>
|
|
83
83
|
now, it uses [`@rmtrollbot/types`](https://www.npmjs.com/package/@rmtrollbot/types) instead of [`rmtrollbot-types`](https://www.npmjs.com/package/rmtrollbot-types), since rmtrollbot-types is deprecated.
|
|
84
|
+
## New for v4.0.0!
|
|
85
|
+
rmtrollbot now uses [`yocto-spinner`](https://www.npmjs.com/package/yocto-spinner) instead of [`ora`](https://www.npmjs.com/package/ora), since ora installs more dependencies than yocto-spinner, and i don't want that.
|
|
86
|
+
### New for v4.1.0!
|
|
87
|
+
Now, the `emit()` function has changed mechanics.
|
|
88
|
+
```ts
|
|
89
|
+
bot.emit("delet") /* Acts normally like socket.emit() */
|
|
90
|
+
|
|
91
|
+
bot.emit("message", "hi!") /* Acts like socket.send() */
|
|
92
|
+
```
|
|
93
|
+
And there is now a `Trollbot.of()` function.
|
|
94
|
+
```ts
|
|
95
|
+
const bot = new Trollbot("clanker", "gray")
|
|
96
|
+
// is the same as...
|
|
97
|
+
const bot = TrollBot.of("clanker", "gray")
|
|
98
|
+
```
|
|
99
|
+
Also there is new documentation! (more soon though...)
|
|
84
100
|
# Extensions
|
|
85
101
|
[`rmtrollbot-decode`](https://www.npmjs.com/package/rmtrollbot-decode?activeTab=readme): Decoder for rmtrollbot<br>
|
|
86
102
|
[`rmtrollbot-ping`](https://www.npmjs.com/package/rmtrollbot-ping): Ping example
|
|
@@ -108,6 +124,9 @@ To install this package by Bun, run the following:
|
|
|
108
124
|
bun add rmtrollbot
|
|
109
125
|
```
|
|
110
126
|
# vs. trollbox-bot
|
|
127
|
+
## From v3.2.2
|
|
111
128
|

|
|
129
|
+
## From v4.0.0
|
|
130
|
+

|
|
112
131
|
# Bots using this package
|
|
113
132
|
None have been recorded, but please use this package
|
package/index.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { init } from "@rmtrollbot/loader";
|
|
2
|
-
import
|
|
2
|
+
import yocto from "yocto-spinner"
|
|
3
3
|
import { message, user, userchangenick, userupdate, rmtbID } from "@rmtrollbot/types"
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The TrollBot instance.
|
|
7
|
+
*/
|
|
5
8
|
export class TrollBot {
|
|
6
9
|
protected name: string;
|
|
7
10
|
protected readonly ogname: string;
|
|
@@ -10,6 +13,12 @@ export class TrollBot {
|
|
|
10
13
|
protected tag: string;
|
|
11
14
|
protected readonly ogtag: string;
|
|
12
15
|
protected socket = init()
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for the TrollBot instance.
|
|
18
|
+
* @param name The name of the bot.
|
|
19
|
+
* @param color The color of the bot.
|
|
20
|
+
* @param tag (Defaults to "bot") The tag for the bot.
|
|
21
|
+
*/
|
|
13
22
|
constructor(name: string, color: string, tag: string = "bot") {
|
|
14
23
|
this.name = name
|
|
15
24
|
this.ogname = name
|
|
@@ -17,13 +26,13 @@ export class TrollBot {
|
|
|
17
26
|
this.ogcolor = color
|
|
18
27
|
this.tag = tag
|
|
19
28
|
this.ogtag = tag
|
|
20
|
-
const spinner =
|
|
29
|
+
const spinner = yocto({
|
|
21
30
|
text: "Connecting...",
|
|
22
31
|
spinner: {
|
|
23
32
|
frames: "rmtrollbot".split("")
|
|
24
33
|
},
|
|
25
34
|
color: "cyan"
|
|
26
|
-
})
|
|
35
|
+
}).start()
|
|
27
36
|
this.socket.on("_connected", () => {
|
|
28
37
|
spinner.text = "Joining..."
|
|
29
38
|
this.socket.emit("user joined", name, color, tag, "")
|
|
@@ -33,12 +42,25 @@ export class TrollBot {
|
|
|
33
42
|
protected rejoin() {
|
|
34
43
|
this.socket.emit("user joined", this.name, this.color, this.tag, "")
|
|
35
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Sends a message
|
|
47
|
+
* @param args The message
|
|
48
|
+
*/
|
|
36
49
|
send(...args: string[]) {
|
|
37
50
|
this.socket.send(...args)
|
|
38
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Executes a callback when a message is sent.
|
|
54
|
+
* @param callback Callback when a message is sent.
|
|
55
|
+
*/
|
|
39
56
|
onMessage(callback: (data: message) => void) {
|
|
40
57
|
this.socket.on("message", callback)
|
|
41
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Executes a callback when a user does a join/leave action.
|
|
61
|
+
* @param event The action.
|
|
62
|
+
* @param callback Callback when the user does a join/leave action.
|
|
63
|
+
*/
|
|
42
64
|
onUser(event: "join" | "leave", callback: (data: user) => void) {
|
|
43
65
|
this.socket.on((event == "join" ? "user joined" : "user left"), callback)
|
|
44
66
|
}
|
|
@@ -48,8 +70,12 @@ export class TrollBot {
|
|
|
48
70
|
onUserUpdate(callback: (data: { [ P: string ]: userupdate }) => void) {
|
|
49
71
|
this.socket.on("update users", callback)
|
|
50
72
|
}
|
|
51
|
-
emit<Ev extends string>(ev: Ev, ...args: any[]) {
|
|
52
|
-
|
|
73
|
+
emit<Ev extends string , Args>(ev: Ev, ...args: Args extends any[] ? Args : Args[]) {
|
|
74
|
+
if (ev == "message"){
|
|
75
|
+
this.socket.send(...args)
|
|
76
|
+
} else {
|
|
77
|
+
this.socket.emit(ev, ...args)
|
|
78
|
+
}
|
|
53
79
|
}
|
|
54
80
|
disconnect() {
|
|
55
81
|
this.socket.disconnect()
|
|
@@ -95,4 +121,7 @@ export class TrollBot {
|
|
|
95
121
|
editByID(id: rmtbID, newt: string) {
|
|
96
122
|
this.socket.emit("edit_ownid", id, newt)
|
|
97
123
|
}
|
|
124
|
+
static of(name: string, color: string, tag: string = "bot"){
|
|
125
|
+
return new TrollBot(name, color, tag)
|
|
126
|
+
}
|
|
98
127
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rmtrollbot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A package making the producing of rmtrollbox bots easier.",
|
|
5
5
|
"main": "index.mts",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
6
|
"keywords": [
|
|
10
7
|
"bot",
|
|
11
8
|
"chat",
|
|
@@ -15,10 +12,13 @@
|
|
|
15
12
|
],
|
|
16
13
|
"author": "",
|
|
17
14
|
"license": "MIT",
|
|
18
|
-
"type": "
|
|
15
|
+
"type": "module",
|
|
19
16
|
"dependencies": {
|
|
20
17
|
"@rmtrollbot/loader": "^1.0.0",
|
|
21
18
|
"@rmtrollbot/types": "^1.0.0",
|
|
22
|
-
"
|
|
19
|
+
"yocto-spinner": "^1.1.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|