-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch package to organization repository.
- Loading branch information
0 parents
commit 10d70ab
Showing
19 changed files
with
1,798 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text eol=lf | ||
*.png binary |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Publish package | ||
run: npx jsr publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# VSCode | ||
.vscode/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"tabWidth": 4, | ||
"endOfLine": "lf", | ||
"semi": true, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/*! | ||
* Callisto, a simple and powerful bot package for nin0-dev's chat server. | ||
* Copyright (c) 2022 Kodarru 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 | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// ****** | ||
// Import the necessary modules. | ||
import { Client, type Callisto } from "../Source/Main.ts"; | ||
|
||
// ****** | ||
|
||
const client = new Client({ | ||
Bot: { | ||
username: "YOUR_BOT_NAME", | ||
key: "YOUR_BOT_KEY", | ||
// Has no use implemented yet. Leave it as an empty array. | ||
staleMessages: [], | ||
}, | ||
Websocket: { | ||
URI: "wss://guhws.nin0.dev", | ||
Reconnect: true, | ||
ReconnectMaxTrials: 5, | ||
}, | ||
LogLevel: 2, | ||
}); | ||
|
||
const Log = client.Logger; | ||
let prefix = "!"; | ||
|
||
// This function will be called when the Websocket is opened. | ||
client.On("open", () => { | ||
Log.Info("Connection established!"); | ||
client.Send("Hello, world! My prefix is " + prefix + ". Type " + prefix + "help for a list of commands."); | ||
}); | ||
|
||
// This function will be called when the Websocket receives a message. | ||
client.On("message", (message: Callisto.Message) => { | ||
// Will not respond to bots. | ||
if (message.isBot()) return; | ||
// Will not respond to itself. | ||
if (message.isSelf()) return; | ||
|
||
/* | ||
* The message object has the following functions: | ||
* | ||
* isMod(): boolean; - Checks if the message was sent by a admin/mod. | ||
* isBot(): boolean; - Checks if the message was sent by a bot. | ||
* isDiscord(): boolean; - Checks if the message was sent from Discord. | ||
* isUser(): boolean; - Checks if the message was sent by a user. | ||
* isSelf(): boolean; - Checks if the message was sent by the bot. | ||
* Send(content: string): void; - Sends a message to the chat. | ||
* Reply(content: string): void; - Replies to the user who sent the message. | ||
*/ | ||
|
||
// Check if the message starts with the prefix. | ||
if (message.content?.startsWith(prefix)) { | ||
// Split the message into an array of arguments. | ||
// Example: !ping hello world | ||
// Output: ["ping", "hello", "world"] | ||
const args = message.content.slice(prefix.length).split(/ +/); | ||
// Shift the first argument from the array. | ||
// Example: ["ping", "hello", "world"] | ||
// Output: "ping" | ||
const command = args.shift()?.toLowerCase(); | ||
|
||
switch (command) { | ||
case "ping": | ||
// message.Reply will reply to the user who sent the message. | ||
// Example: message.Reply("Pong!"); | ||
// Output: Replying to <username>: Pong! | ||
message.Reply("Pong!"); | ||
break; | ||
case "prefix": | ||
prefix = args[0]; | ||
message.Reply("Prefix set to " + prefix); | ||
break; | ||
case "say": | ||
// message.Send will send a message to the chat. | ||
// Example: message.Send("Hello, world!"); | ||
// Output: Hello, world! | ||
// Note: This will not reply to the user. | ||
message.Send(args.join(" ")); | ||
break; | ||
case "help": | ||
message.Reply("Commands: help, ping, say, prefix"); | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
// Connects to the Websocket server. | ||
client.Connect(); |
Oops, something went wrong.