{"id":25030216,"url":"https://github.com/fadhil-riyanto/gwkang-ts","last_synced_at":"2026-02-15T13:34:20.823Z","repository":{"id":271469724,"uuid":"913256064","full_name":"fadhil-riyanto/gwkang-ts","owner":"fadhil-riyanto","description":"GNU/Weeb sticker bot rewrite from python to typescript, with feature enchantment","archived":false,"fork":false,"pushed_at":"2025-01-29T11:25:16.000Z","size":145,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T19:51:08.543Z","etag":null,"topics":["bot","telegram-bot"],"latest_commit_sha":null,"homepage":"https://t.me/kangutils_bot","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fadhil-riyanto.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-07T10:31:25.000Z","updated_at":"2025-01-29T11:25:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"c95a2d14-9ccd-46b8-8251-15e036a51e1b","html_url":"https://github.com/fadhil-riyanto/gwkang-ts","commit_stats":null,"previous_names":["fadhil-riyanto/gwkang-ts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fadhil-riyanto/gwkang-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadhil-riyanto%2Fgwkang-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadhil-riyanto%2Fgwkang-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadhil-riyanto%2Fgwkang-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadhil-riyanto%2Fgwkang-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fadhil-riyanto","download_url":"https://codeload.github.com/fadhil-riyanto/gwkang-ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadhil-riyanto%2Fgwkang-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29479866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","telegram-bot"],"created_at":"2025-02-05T21:58:04.944Z","updated_at":"2026-02-15T13:34:20.809Z","avatar_url":"https://github.com/fadhil-riyanto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quick Start Guide\n\n## Table of Contents\n- [Quick Start Guide](#quick-start-guide)\n  - [Table of Contents](#table-of-contents)\n  - [Bot Initialization](#bot-initialization)\n  - [Registering Commands and Middlewares](#registering-commands-and-middlewares)\n  - [Creating Commands](#creating-commands)\n    - [Simple Command](#simple-command)\n    - [Database Command](#database-command)\n  - [Models](#models)\n    - [User Model](#user-model)\n    - [Creating Models](#creating-models)\n  - [Database Operations](#database-operations)\n\n## Bot Initialization\nInitialize the bot with the following configuration:\n```typescript\nimport { createBot } from './src/core/bot';\n\nconst main = async () =\u003e {\n  const bot = await createBot({\n    setMyCommands: true,\n    bot: {\n      client: {\n        // Bot client options\n      },\n    },\n  });\n\n  await bot.start({\n    // Start options\n  });\n};\n```\n\n## Registering Commands and Middlewares\nAdd your commands and middlewares to the registry:\n```typescript\n// Register middlewares, commands and models in registry.ts\nexport const middlewares = [\n  rateLimit,\n  // Add more middlewares here\n];\n\nexport const commands = [\n  ping,\n  start,\n  // Add more commands here\n];\n\nexport const models = [\n  model('User', UserSchema),\n  // Add more models here\n];\n```\n\n## Creating Commands\nCommands are created using the `createCommand` function:\n\n### Simple Command\nBasic command without any special handling:\n```typescript\nimport { createCommand } from '../utils/command';\n\nconst ping = createCommand(\n  {\n    name: 'ping',\n    description: 'Check bot status',\n  },\n  async ctx =\u003e {\n    const start = Date.now();\n    await ctx.reply('Calculating ping...');\n    const end = Date.now();\n    await ctx.reply(`Pong! Response time: ${end - start}ms`);\n  }\n);\n\nexport default ping;\n```\n\n### Database Command\nCommand that interacts with the database:\n```typescript\nconst start = createCommand(\n  {\n    name: 'start',\n    description: 'Start the bot',\n  },\n  async ctx =\u003e {\n    try {\n      if (!ctx.from) {\n        await ctx.reply('Error: Could not identify user');\n        return;\n      }\n\n      const User = ctx.db.model\u003cIUser\u003e('User');\n      const user = await User.findOne({ userId: ctx.from.id });\n      \n      if (!user) {\n        await User.create({\n          userId: ctx.from.id,\n          username: ctx.from.username || undefined,\n          firstName: ctx.from.first_name || undefined,\n          lastName: ctx.from.last_name || undefined,\n        });\n        await ctx.reply('Welcome to the bot!');\n      } else {\n        await ctx.reply('Welcome back!');\n      }\n    } catch (error) {\n      console.error('Error in start command:', error);\n      await ctx.reply('An error occurred');\n    }\n  }\n);\n```\n\n## Models\n\n### User Model\nThe built-in User model for tracking bot users:\n```typescript\ninterface IUser extends Document {\n  userId: number;\n  username?: string;\n  firstName?: string;\n  lastName?: string;\n  createdAt: Date;\n  updatedAt: Date;\n}\n\nconst UserSchema = new Schema(\n  {\n    userId: {\n      type: Number,\n      required: true,\n      unique: true,\n    },\n    username: {\n      type: String,\n      required: false,\n    },\n    firstName: {\n      type: String,\n      required: false,\n    },\n    lastName: {\n      type: String,\n      required: false,\n    },\n  },\n  {\n    timestamps: true,\n  }\n);\n```\n\n### Creating Models\nExample of creating a custom model:\n```typescript\nconst customSchema = new Schema({\n  field: { type: String, required: true },\n  // Add more fields\n}, {\n  timestamps: true\n});\n\n// Register in registry.ts\nexport const models = [\n  model('Custom', customSchema),\n  // Other models\n];\n```\n\n## Database Operations\nCommon database operations using Mongoose:\n```typescript\n// Create\nconst doc = await Model.create({ field: value });\n\n// Read\nconst docs = await Model.find({ field: value });\nconst doc = await Model.findOne({ field: value });\n\n// Update\nawait Model.updateOne(\n  { field: value },\n  { $set: { updatedField: newValue } }\n);\n\n// Delete\nawait Model.deleteOne({ field: value });\n\n// Pagination\nconst docs = await Model.find()\n  .skip((page - 1) * perPage)\n  .limit(perPage);\n\n// Sorting\nconst docs = await Model.find().sort({ createdAt: -1 });\n\n// Complex Query\nconst docs = await Model.find({\n  field1: { $gt: value },\n  field2: { $in: arrayOfValues },\n  field3: /pattern/i\n});\n\n// Aggregation\nconst results = await Model.aggregate([\n  { $match: { field: value } },\n  { $group: { _id: '$groupField', total: { $sum: 1 } } }\n]);\n``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadhil-riyanto%2Fgwkang-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffadhil-riyanto%2Fgwkang-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadhil-riyanto%2Fgwkang-ts/lists"}