rmtrollbot 5.0.0 → 6.0.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 +10 -0
- package/index.mts +33 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,16 @@ Also there is new documentation! (more soon though...)
|
|
|
101
101
|
Since the owner (a.k.a. agzgt2) is going to KidZania soon, i added KidZania easter eggs!
|
|
102
102
|
## New for v5.0.0!
|
|
103
103
|
Removal of the KidZania easter eggs have been made, please use [`@rmtrollbot/kidzania`](https://www.npmjs.com/package/@rmtrollbot/kidzania) instead.
|
|
104
|
+
## New for v6.0.0!
|
|
105
|
+
You can control which thing to change back now!
|
|
106
|
+
```ts
|
|
107
|
+
bot.changeBack() // Changes name, color, and tag
|
|
108
|
+
bot.changeBack({ name: true, tag: true }) // Changes name, and tag
|
|
109
|
+
```
|
|
110
|
+
You can also chain commands now!
|
|
111
|
+
```ts
|
|
112
|
+
bot.changeNick("le clanker").send("beep beep boop")
|
|
113
|
+
```
|
|
104
114
|
# Extensions
|
|
105
115
|
[`rmtrollbot-decode`](https://www.npmjs.com/package/rmtrollbot-decode?activeTab=readme): Decoder for rmtrollbot<br>
|
|
106
116
|
[`rmtrollbot-ping`](https://www.npmjs.com/package/rmtrollbot-ping): Ping example
|
package/index.mts
CHANGED
|
@@ -2,6 +2,12 @@ import { init } from "@rmtrollbot/loader";
|
|
|
2
2
|
import yocto from "yocto-spinner"
|
|
3
3
|
import { message, user, userchangenick, userupdate, rmtbID } from "@rmtrollbot/types"
|
|
4
4
|
|
|
5
|
+
type BackSettings = {
|
|
6
|
+
name?: boolean;
|
|
7
|
+
color?: boolean;
|
|
8
|
+
tag?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* The TrollBot instance.
|
|
7
13
|
*/
|
|
@@ -20,7 +26,6 @@ export class TrollBot {
|
|
|
20
26
|
* @param tag (Defaults to "bot") The tag for the bot.
|
|
21
27
|
*/
|
|
22
28
|
constructor(name: string, color: string, tag: string = "bot") {
|
|
23
|
-
console.log("I AM GOING TO KIDZANIA!!!")
|
|
24
29
|
this.name = name
|
|
25
30
|
this.ogname = name
|
|
26
31
|
this.color = color
|
|
@@ -49,6 +54,7 @@ export class TrollBot {
|
|
|
49
54
|
*/
|
|
50
55
|
send(...args: string[]) {
|
|
51
56
|
this.socket.send(...args)
|
|
57
|
+
return this
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* Executes a callback when a message is sent.
|
|
@@ -56,6 +62,7 @@ export class TrollBot {
|
|
|
56
62
|
*/
|
|
57
63
|
onMessage(callback: (data: message) => void) {
|
|
58
64
|
this.socket.on("message", callback)
|
|
65
|
+
return this
|
|
59
66
|
}
|
|
60
67
|
/**
|
|
61
68
|
* Executes a callback when a user does a join/leave action.
|
|
@@ -64,26 +71,32 @@ export class TrollBot {
|
|
|
64
71
|
*/
|
|
65
72
|
onUser(event: "join" | "leave", callback: (data: user) => void) {
|
|
66
73
|
this.socket.on((event == "join" ? "user joined" : "user left"), callback)
|
|
74
|
+
return this
|
|
67
75
|
}
|
|
68
76
|
onNickChange(callback: (olduser: userchangenick, newuser: userchangenick) => void) {
|
|
69
77
|
this.socket.on("user change nick", callback)
|
|
78
|
+
return this
|
|
70
79
|
}
|
|
71
80
|
onUserUpdate(callback: (data: { [ P: string ]: userupdate }) => void) {
|
|
72
81
|
this.socket.on("update users", callback)
|
|
82
|
+
return this
|
|
73
83
|
}
|
|
74
|
-
emit<Ev extends string
|
|
75
|
-
if (ev == "message"){
|
|
84
|
+
emit<Ev extends string, Args>(ev: Ev, ...args: Args extends any[] ? Args : Args[]) {
|
|
85
|
+
if (ev == "message") {
|
|
76
86
|
this.socket.send(...args)
|
|
77
87
|
} else {
|
|
78
88
|
this.socket.emit(ev, ...args)
|
|
79
89
|
}
|
|
90
|
+
return this
|
|
80
91
|
}
|
|
81
92
|
disconnect() {
|
|
82
93
|
this.socket.disconnect()
|
|
94
|
+
return this
|
|
83
95
|
}
|
|
84
96
|
changeNick(newn: string) {
|
|
85
97
|
this.name = newn
|
|
86
98
|
this.rejoin()
|
|
99
|
+
return this
|
|
87
100
|
}
|
|
88
101
|
changeColor(newc: string) {
|
|
89
102
|
if (!newc.includes("272822")) {
|
|
@@ -92,37 +105,51 @@ export class TrollBot {
|
|
|
92
105
|
} else {
|
|
93
106
|
this.socket.send("NICE TRY!!")
|
|
94
107
|
}
|
|
108
|
+
return this
|
|
95
109
|
}
|
|
96
110
|
changeTag(newt: string) {
|
|
97
111
|
this.tag = newt
|
|
98
112
|
this.rejoin()
|
|
113
|
+
return this
|
|
99
114
|
}
|
|
100
|
-
changeBack() {
|
|
101
|
-
[ this.name, this.color, this.tag ] = [ this.ogcolor, this.ogname, this.ogtag ]
|
|
115
|
+
changeBack(settings?: BackSettings) {
|
|
116
|
+
if (settings == undefined) { [ this.name, this.color, this.tag ] = [ this.ogcolor, this.ogname, this.ogtag ] } else {
|
|
117
|
+
if (settings.name) this.changeNick(this.ogname)
|
|
118
|
+
if (settings.color) this.changeColor(this.ogcolor)
|
|
119
|
+
if (settings.tag) this.changeTag(this.ogtag)
|
|
120
|
+
}
|
|
102
121
|
this.rejoin()
|
|
122
|
+
return this
|
|
103
123
|
}
|
|
104
124
|
lastMessageID(callback: (id: rmtbID) => void) {
|
|
105
125
|
this.socket.once("lts_msgid", callback)
|
|
126
|
+
return this
|
|
106
127
|
}
|
|
107
128
|
deleteLastMessage() {
|
|
108
129
|
this.socket.emit("delet")
|
|
130
|
+
return this
|
|
109
131
|
}
|
|
110
132
|
onMessageDelete(callback: (id: rmtbID) => void) {
|
|
111
133
|
this.socket.on("delet", callback)
|
|
134
|
+
return this
|
|
112
135
|
}
|
|
113
136
|
deleteByID(id: rmtbID) {
|
|
114
137
|
this.socket.emit("delete_ownid", id)
|
|
138
|
+
return this
|
|
115
139
|
}
|
|
116
140
|
onEdit(callback: (id: rmtbID, text: string) => void) {
|
|
117
141
|
this.socket.on("edited", callback)
|
|
142
|
+
return this
|
|
118
143
|
}
|
|
119
144
|
editLastMessage(newt: string) {
|
|
120
145
|
this.socket.emit("edit", newt)
|
|
146
|
+
return this
|
|
121
147
|
}
|
|
122
148
|
editByID(id: rmtbID, newt: string) {
|
|
123
149
|
this.socket.emit("edit_ownid", id, newt)
|
|
150
|
+
return this
|
|
124
151
|
}
|
|
125
|
-
static of(name: string, color: string, tag: string = "bot"){
|
|
152
|
+
static of(name: string, color: string, tag: string = "bot") {
|
|
126
153
|
return new TrollBot(name, color, tag)
|
|
127
154
|
}
|
|
128
155
|
}
|