Skip to content

Commit

Permalink
0.1.2 - New update! Check Releases.md for more information!
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodarru committed Oct 18, 2024
1 parent 36aae43 commit f02fe95
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 18 deletions.
9 changes: 8 additions & 1 deletion Example/Main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -53,6 +53,13 @@ client.On("message", (message: Callisto.Message) => {
// Will not respond to itself.
if (message.isSelf()) return;

// Will reply to the user if they mentioned the bot.
// Example: "Hello, @Ko-Ko!"
// Output: "Replying to <username>: You mentioned me!"
if (message.isMentioned()) {
message.Reply("You mentioned me!");
}

/*
* The message object has the following functions:
*
Expand Down
26 changes: 20 additions & 6 deletions Releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

---

## Version `0.1.2` 📝

- Added `<Message>.isMentioned` method. This property is used to check if the message is mentioning the bot.
- Example:
```ts
client.On("message", (message) => {
if (message.isMentioned()) {
message.Reply("Hello!");
}
});
```
- Improved logging for WebSocket events.
- Updated license notices at the top of each file to reflect the new repository owner change.

Update to this version by running the following command in your terminal:

```bash
deno add jsr:@nin0chat/[email protected]
```

## Version `0.1.1` 📝

- Added `<Client>.Once` method. This method is the same as `<Client>.On`, but it only runs once.
Expand All @@ -31,9 +51,3 @@
- `@/Main.ts`
- `@/Utilities/Types.ts`
- `@/Utilities/Logger.ts`

Update to this version by running the following command in your terminal:

```bash
deno add jsr:@nin0chat/[email protected]
```
3 changes: 2 additions & 1 deletion Source/Handlers/Close.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,7 @@ import type { Client } from "@/Main.ts";

export function On_Close(client: Client) {
return () => {
client.Logger.Debug("Event Handler `On_Close` has been triggered.");
client.Emit("close", client);

if (client.DisconnectIntentional) return;
Expand Down
3 changes: 2 additions & 1 deletion Source/Handlers/Error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,7 @@ import type { Client } from "@/Main.ts";

export function On_Error(error: string, client: Client) {
return () => {
client.Logger.Debug("Event Handler `On_Error` has been triggered.");
client.Emit("error");
client.Logger.Error("An unexpected error occurred! " + error);
};
Expand Down
8 changes: 5 additions & 3 deletions Source/Handlers/Message.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,13 +19,12 @@
// ******

import type { Client } from "@/Main.ts";
import type * as Callisto from "@/Utilities/Types.ts";
import * as Constants from "@/Utilities/Constants.ts";

// ******

export function On_Message(data: any, client: Client) {
client.Logger.Debug("Received new message");
client.Logger.Debug("Event Handler `On_Message` has been triggered.");

const _data = JSON.parse(data.toString());

Expand All @@ -48,6 +47,9 @@ export function On_Message(data: any, client: Client) {
isSelf: function () {
return _data.username === client.ClientData.username;
},
isMentioned: function () {
return _data.content?.includes(client.ClientData.username);
},
Send: function (content: string) {
client.Send(content);
},
Expand Down
3 changes: 2 additions & 1 deletion Source/Handlers/Open.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,7 @@ import type { Client } from "@/Main.ts";

export function On_Open(client: Client) {
return () => {
client.Logger.Debug("Event Handler `On_Open` has been triggered.");
client.Emit("open");
};
}
2 changes: 1 addition & 1 deletion Source/Main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev"s chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion Source/Utilities/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion Source/Utilities/Logging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 3 additions & 1 deletion Source/Utilities/Types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Callisto, a simple and powerful bot package for nin0-dev's chat server.
* Copyright (c) 2022 Kodarru and contributors.
* Copyright (c) 2022 nin0chat and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,6 +35,7 @@
* @property {function} isDiscord - Checks if the message was sent by Discord.
* @property {function} isUser - Checks if the message was sent by a user.
* @property {function} isSelf - Checks if the message was sent by the bot itself.
* @property {function} isMentioned - Checks if the bot was mentioned in the message.
* @property {function} Send - Sends a message to the chat server.
* @property {function} Reply - Replies to the message.
*/
Expand All @@ -60,6 +61,7 @@ export interface Message {
isDiscord(): boolean;
isUser(): boolean;
isSelf(): boolean;
isMentioned(): boolean;
Send(content: string): void;
Reply(content: string): void;
}
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nin0chat/callisto",
"version": "0.1.1",
"version": "0.1.2",
"exports": "./Source/Main.ts",
"imports": {
"@std/assert": "jsr:@std/assert@1",
Expand Down

0 comments on commit f02fe95

Please sign in to comment.