Skip to content

Commit

Permalink
chore: add gramio example
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Jun 16, 2024
1 parent 9476861 commit a2b63b0
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example/gramio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# gramio

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.1.13. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
12 changes: 12 additions & 0 deletions example/gramio/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import autoload from "../../src";

await Bun.build({
entrypoints: ["./index.ts"],
outdir: "out",
target: "bun",
plugins: [
autoload({
directory: "./commands",
}),
],
}).then(console.log);
Binary file added example/gramio/bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions example/gramio/commands/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// commands/command.ts
import type { BotType } from "..";

export default (bot: BotType) =>
bot.command("start", (context) => context.send("hello!"));
11 changes: 11 additions & 0 deletions example/gramio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { autoload } from "@gramio/autoload";
// index.ts
import { Bot } from "gramio";

const bot = new Bot(process.env.TOKEN as string)
.extend(autoload())
.onStart(console.log);

bot.start();

export type BotType = typeof bot;
15 changes: 15 additions & 0 deletions example/gramio/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "gramio",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@gramio/autoload": "^0.0.4",
"gramio": "^0.0.39"
}
}
27 changes: 27 additions & 0 deletions example/gramio/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}

0 comments on commit a2b63b0

Please sign in to comment.