rmtrollbot 2.1.2 → 3.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 +28 -2
- package/index.mts +27 -6
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# Reversed Meow TrollBot
|
|
2
2
|
[](https://packagequality.com/#?package=rmtrollbot)
|
|
3
|
-
|
|
3
|
+
# About
|
|
4
4
|
A package making the producing of rmtrollbox bots easier.<br>
|
|
5
5
|
To start a bot, you must start a new TrollBot element.
|
|
6
|
-
|
|
7
6
|
```ts
|
|
8
7
|
let bot = new TrollBot("clanker", "gray")
|
|
9
8
|
```
|
|
@@ -48,6 +47,33 @@ Same as for v1.1.0, you can also change the tag!
|
|
|
48
47
|
bot.changeTag("") // Changes tag from "bot" to ""
|
|
49
48
|
bot.changeBack() // Changes tag back to "bot"
|
|
50
49
|
```
|
|
50
|
+
## New for v3.0.0!
|
|
51
|
+
This package now uses [@rmtrollbot/loader](https://www.npmjs.com/package/@rmtrollbot/loader) instead of [socket.io-client](https://www.npmjs.com/package/socket.io-client)<br>
|
|
52
|
+
Also there is now support for editing, deleting, and IDs!
|
|
53
|
+
```ts
|
|
54
|
+
/* Deleting last message */
|
|
55
|
+
bot.send("FREE ROBUX AT [redacted]")
|
|
56
|
+
bot.deleteLastMessage()
|
|
57
|
+
|
|
58
|
+
/* On message deletion */
|
|
59
|
+
bot.onMessageDelete((id)=>{
|
|
60
|
+
console.log(`Message with id ${id} has been deleted!`)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/* Deleting by ID + Getting ID */
|
|
64
|
+
bot.send("freak bait!")
|
|
65
|
+
bot.lastMessageID((id)=>{
|
|
66
|
+
bot.deleteByID(id)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
/* Editing message (both by ID and by last message) */
|
|
70
|
+
bot.send("secret message!")
|
|
71
|
+
bot.editLastMessage("awh... you missed it!")
|
|
72
|
+
// or...
|
|
73
|
+
bot.lastMessageID((id)=>{
|
|
74
|
+
bot.editByID(id, "awh... you missed it!")
|
|
75
|
+
})
|
|
76
|
+
```
|
|
51
77
|
# Extensions
|
|
52
78
|
[rmtrollbot-decode](https://www.npmjs.com/package/rmtrollbot-decode?activeTab=readme): Decoder for rmtrollbot<br>
|
|
53
79
|
[rmtrollbot-ping](https://www.npmjs.com/package/rmtrollbot-ping): Ping example
|
package/index.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { init } from "@rmtrollbot/loader";
|
|
2
2
|
// import { Decoder } from "rmtrollbot-decode"
|
|
3
|
-
import { message, user, userchangenick, userupdate } from "rmtrollbot-types"
|
|
3
|
+
import { message, user, userchangenick, userupdate, rmtbID } from "rmtrollbot-types"
|
|
4
4
|
|
|
5
5
|
export class TrollBot {
|
|
6
6
|
// protected ext: Decoder | undefined; // DEPRECATED
|
|
@@ -10,7 +10,7 @@ export class TrollBot {
|
|
|
10
10
|
protected readonly ogcolor: string;
|
|
11
11
|
protected tag: string;
|
|
12
12
|
protected readonly ogtag: string;
|
|
13
|
-
protected socket =
|
|
13
|
+
protected socket = init()
|
|
14
14
|
constructor(name: string, color: string, tag: string = "bot") {
|
|
15
15
|
this.name = name
|
|
16
16
|
this.ogname = name
|
|
@@ -21,7 +21,7 @@ export class TrollBot {
|
|
|
21
21
|
/// this.ext = extension
|
|
22
22
|
this.socket.emit("user joined", name, color, tag, "")
|
|
23
23
|
}
|
|
24
|
-
protected rejoin(){
|
|
24
|
+
protected rejoin() {
|
|
25
25
|
this.socket.emit("user joined", this.name, this.color, this.tag, "")
|
|
26
26
|
}
|
|
27
27
|
send(...args: string[]) {
|
|
@@ -36,7 +36,7 @@ export class TrollBot {
|
|
|
36
36
|
onNickChange(callback: (olduser: userchangenick, newuser: userchangenick) => void) {
|
|
37
37
|
this.socket.on("user change nick", callback)
|
|
38
38
|
}
|
|
39
|
-
onUserUpdate(callback: (data: {[P: string]: userupdate}) => void) {
|
|
39
|
+
onUserUpdate(callback: (data: { [P: string]: userupdate }) => void) {
|
|
40
40
|
this.socket.on("update users", callback)
|
|
41
41
|
}
|
|
42
42
|
emit<Ev extends string>(ev: Ev, ...args: any[]) {
|
|
@@ -57,7 +57,7 @@ export class TrollBot {
|
|
|
57
57
|
this.socket.send("NICE TRY!!")
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
changeTag(newt: string){
|
|
60
|
+
changeTag(newt: string) {
|
|
61
61
|
this.tag = newt
|
|
62
62
|
this.rejoin()
|
|
63
63
|
}
|
|
@@ -65,4 +65,25 @@ export class TrollBot {
|
|
|
65
65
|
[this.name, this.color, this.tag] = [this.ogcolor, this.ogname, this.ogtag]
|
|
66
66
|
this.rejoin()
|
|
67
67
|
}
|
|
68
|
+
lastMessageID(callback: (id: rmtbID) => void) {
|
|
69
|
+
this.socket.once("lts_msgid", callback)
|
|
70
|
+
}
|
|
71
|
+
deleteLastMessage() {
|
|
72
|
+
this.socket.emit("delet")
|
|
73
|
+
}
|
|
74
|
+
onMessageDelete(callback: (id: rmtbID) => void) {
|
|
75
|
+
this.socket.on("delet", callback)
|
|
76
|
+
}
|
|
77
|
+
deleteByID(id: rmtbID) {
|
|
78
|
+
this.socket.emit("delete_ownid", id)
|
|
79
|
+
}
|
|
80
|
+
onEdit(callback: (id: rmtbID, text: string) => void) {
|
|
81
|
+
this.socket.on("edited", callback)
|
|
82
|
+
}
|
|
83
|
+
editLastMessage(newt: string){
|
|
84
|
+
this.socket.emit("edit", newt)
|
|
85
|
+
}
|
|
86
|
+
editByID(id: rmtbID, newt: string){
|
|
87
|
+
this.socket.emit("edit_ownid", id, newt)
|
|
88
|
+
}
|
|
68
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rmtrollbot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A package making the producing of rmtrollbox bots easier.",
|
|
5
5
|
"main": "index.mts",
|
|
6
6
|
"scripts": {
|
|
@@ -17,10 +17,7 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"type": "commonjs",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"rmtrollbot
|
|
21
|
-
"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/he": "^1.2.3"
|
|
20
|
+
"@rmtrollbot/loader": "^1.0.0",
|
|
21
|
+
"rmtrollbot-types": "^1.0.0"
|
|
25
22
|
}
|
|
26
23
|
}
|