From a2b63b0397508f3a89932dfd3224996e0e1b82e3 Mon Sep 17 00:00:00 2001 From: Kravets <57632712+kravetsone@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:38:52 +0300 Subject: [PATCH] chore: add gramio example --- example/gramio/README.md | 15 +++++++++++++++ example/gramio/build.ts | 12 ++++++++++++ example/gramio/bun.lockb | Bin 0 -> 19950 bytes example/gramio/commands/command.ts | 5 +++++ example/gramio/index.ts | 11 +++++++++++ example/gramio/package.json | 15 +++++++++++++++ example/gramio/tsconfig.json | 27 +++++++++++++++++++++++++++ 7 files changed, 85 insertions(+) create mode 100644 example/gramio/README.md create mode 100644 example/gramio/build.ts create mode 100644 example/gramio/bun.lockb create mode 100644 example/gramio/commands/command.ts create mode 100644 example/gramio/index.ts create mode 100644 example/gramio/package.json create mode 100644 example/gramio/tsconfig.json diff --git a/example/gramio/README.md b/example/gramio/README.md new file mode 100644 index 0000000..2ce5d1c --- /dev/null +++ b/example/gramio/README.md @@ -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. diff --git a/example/gramio/build.ts b/example/gramio/build.ts new file mode 100644 index 0000000..99153d2 --- /dev/null +++ b/example/gramio/build.ts @@ -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); diff --git a/example/gramio/bun.lockb b/example/gramio/bun.lockb new file mode 100644 index 0000000000000000000000000000000000000000..a86657ff8a8adab0a03cde15e2927a0dfda70462 GIT binary patch literal 19950 zcmeHPc|28J_rG)#N=m3mkp|Jd<}nEk-iRU*MP1j$HC^0mXjVxjNpndwX+VQCX%dx? zQc@aJ8Was0pXaGG{MI_|=G6Oyp5O0}_xE|*pHBPiv-kJA*Is+=;p}r4O%2^hVT7&^ zKU9|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ramio/commands/command.ts new file mode 100644 index 0000000..e054e21 --- /dev/null +++ b/example/gramio/commands/command.ts @@ -0,0 +1,5 @@ +// commands/command.ts +import type { BotType } from ".."; + +export default (bot: BotType) => + bot.command("start", (context) => context.send("hello!")); diff --git a/example/gramio/index.ts b/example/gramio/index.ts new file mode 100644 index 0000000..1c1a8fe --- /dev/null +++ b/example/gramio/index.ts @@ -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; diff --git a/example/gramio/package.json b/example/gramio/package.json new file mode 100644 index 0000000..95e4b50 --- /dev/null +++ b/example/gramio/package.json @@ -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" + } +} \ No newline at end of file diff --git a/example/gramio/tsconfig.json b/example/gramio/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/example/gramio/tsconfig.json @@ -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 + } +}