rmtrollbot 4.0.0 → 4.2.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.
Files changed (3) hide show
  1. package/README.md +21 -2
  2. package/index.mts +42 -2
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Reversed Meow TrollBot
1
+ # ![Reversed Meow TrollBot](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Windows_93_logo.svg/250px-Windows_93_logo.svg.png)
2
2
  [![Package Quality](https://packagequality.com/badge/rmtrollbot.png)](https://packagequality.com/#?package=rmtrollbot)![NPM (prod) Dependency Version](https://img.shields.io/npm/dependency-version/rmtrollbot/%40rmtrollbot%2Floader)![NPM (prod) Dependency Version](https://img.shields.io/npm/dependency-version/rmtrollbot/%40rmtrollbot%2Ftypes)![NPM Downloads](https://img.shields.io/npm/dy/rmtrollbot?logo=npm&color=blue)[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")
@@ -83,6 +83,22 @@ 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
84
  ## New for v4.0.0!
85
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...)
100
+ ### New for v4.2.0!
101
+ Since the owner (a.k.a. agzgt2) is going to KidZania soon, i added KidZania easter eggs!
86
102
  # Extensions
87
103
  [`rmtrollbot-decode`](https://www.npmjs.com/package/rmtrollbot-decode?activeTab=readme): Decoder for rmtrollbot<br>
88
104
  [`rmtrollbot-ping`](https://www.npmjs.com/package/rmtrollbot-ping): Ping example
@@ -110,6 +126,9 @@ To install this package by Bun, run the following:
110
126
  bun add rmtrollbot
111
127
  ```
112
128
  # vs. trollbox-bot
129
+ ## From v3.2.2
113
130
  ![Comparison between trollbox-bot and rmtrollbot](https://iili.io/BgZPC0P.png)
131
+ ## From v4.0.0
132
+ ![Comparison between trollbox-bot and rmtrollbot](https://iili.io/B4sJKdJ.png)
114
133
  # Bots using this package
115
134
  None have been recorded, but please use this package
package/index.mts CHANGED
@@ -2,6 +2,9 @@ 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
+ /**
6
+ * The TrollBot instance.
7
+ */
5
8
  export class TrollBot {
6
9
  protected name: string;
7
10
  protected readonly ogname: string;
@@ -10,7 +13,14 @@ 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") {
23
+ console.log("I AM GOING TO KIDZANIA!!!")
14
24
  this.name = name
15
25
  this.ogname = name
16
26
  this.color = color
@@ -33,12 +43,25 @@ export class TrollBot {
33
43
  protected rejoin() {
34
44
  this.socket.emit("user joined", this.name, this.color, this.tag, "")
35
45
  }
46
+ /**
47
+ * Sends a message
48
+ * @param args The message
49
+ */
36
50
  send(...args: string[]) {
37
51
  this.socket.send(...args)
38
52
  }
53
+ /**
54
+ * Executes a callback when a message is sent.
55
+ * @param callback Callback when a message is sent.
56
+ */
39
57
  onMessage(callback: (data: message) => void) {
40
58
  this.socket.on("message", callback)
41
59
  }
60
+ /**
61
+ * Executes a callback when a user does a join/leave action.
62
+ * @param event The action.
63
+ * @param callback Callback when the user does a join/leave action.
64
+ */
42
65
  onUser(event: "join" | "leave", callback: (data: user) => void) {
43
66
  this.socket.on((event == "join" ? "user joined" : "user left"), callback)
44
67
  }
@@ -48,8 +71,12 @@ export class TrollBot {
48
71
  onUserUpdate(callback: (data: { [ P: string ]: userupdate }) => void) {
49
72
  this.socket.on("update users", callback)
50
73
  }
51
- emit<Ev extends string>(ev: Ev, ...args: any[]) {
52
- this.socket.emit(ev, ...args)
74
+ emit<Ev extends string , Args>(ev: Ev, ...args: Args extends any[] ? Args : Args[]) {
75
+ if (ev == "message"){
76
+ this.socket.send(...args)
77
+ } else {
78
+ this.socket.emit(ev, ...args)
79
+ }
53
80
  }
54
81
  disconnect() {
55
82
  this.socket.disconnect()
@@ -95,4 +122,17 @@ export class TrollBot {
95
122
  editByID(id: rmtbID, newt: string) {
96
123
  this.socket.emit("edit_ownid", id, newt)
97
124
  }
125
+ kidzania(){
126
+ this.socket.send("The owner of <a href=\"https://www.npmjs.com/package/rmtrollbot\">this package</a> is going to kidzania!")
127
+ }
128
+ static of(name: string, color: string, tag: string = "bot"){
129
+ return new TrollBot(name, color, tag)
130
+ }
131
+ static kidzania(bot?: TrollBot){
132
+ if (bot){
133
+ bot.send("The owner of <a href=\"https://www.npmjs.com/package/rmtrollbot\">this package</a> is going to kidzania!")
134
+ } else {
135
+ console.log("agzgt2 is going to KidZania!")
136
+ }
137
+ }
98
138
  }
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "rmtrollbot",
3
- "version": "4.0.0",
3
+ "version": "4.2.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",
@@ -20,5 +17,8 @@
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
+ }