{"id":24794846,"url":"https://github.com/yusixian/cos-tg-bot-template","last_synced_at":"2026-05-08T04:09:44.723Z","repository":{"id":274464260,"uuid":"922949343","full_name":"yusixian/cos-tg-bot-template","owner":"yusixian","description":"grammy + prisma + SQLite + pm2 驱动的 tg bot template","archived":false,"fork":false,"pushed_at":"2025-01-27T13:25:15.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T18:49:35.285Z","etag":null,"topics":["grammy","node","pm2","prisma","s3","sqlite","telegram","telegram-bot","ts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusixian.png","metadata":{"files":{"readme":"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-27T11:35:06.000Z","updated_at":"2025-01-27T13:25:18.000Z","dependencies_parsed_at":"2025-01-27T14:27:16.964Z","dependency_job_id":"08b3db7f-c285-4a02-af34-e7d4bd8a3299","html_url":"https://github.com/yusixian/cos-tg-bot-template","commit_stats":null,"previous_names":["yusixian/cos-tg-bot-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/yusixian/cos-tg-bot-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusixian%2Fcos-tg-bot-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusixian%2Fcos-tg-bot-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusixian%2Fcos-tg-bot-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusixian%2Fcos-tg-bot-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusixian","download_url":"https://codeload.github.com/yusixian/cos-tg-bot-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusixian%2Fcos-tg-bot-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265688333,"owners_count":23811416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["grammy","node","pm2","prisma","s3","sqlite","telegram","telegram-bot","ts"],"created_at":"2025-01-29T23:18:31.630Z","updated_at":"2026-05-08T04:09:39.696Z","avatar_url":"https://github.com/yusixian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cos-tg-bot-template\n\n从 [SomeACG/cosine-pic-bot](https://github.com/SomeACG/cosine-pic-bot) 抽离而来的 template 保留了一些开发 bot 需要的通用配置和依赖，可以按需去掉\n\n- 使用 [grammy](https://grammy.dev/) 调用 telegram api\n- 使用 pino 进行日志记录\n- 使用 prisma + SQLite 进行数据库操作\n- 使用 [@aws-sdk/client-s3](https://github.com/aws-sdk-js-v3/aws-sdk-js-v3/tree/main/packages/client-s3) 进行 SQLite 数据库 S3 备份（可选）\n\n## 开发步骤\n\n启动\n\n```bash\npnpm i\npnpm db:init # 如果是全新启动，第一次启动前使用，初始化数据库， 见 [prisma](https://www.prisma.io/docs/orm/prisma-migrate/workflows/development-and-production#create-and-apply-migrations)\n\npnpm pm2 # pm2 启动守护进程，配置文件见 ecosystem.config.js\n#or\npnpm start # 直接终端起方便调试，可以 Ctrl+C 中断\n```\n\n其他命令（问就是个人习惯）：\n\n```bash\npnpm pm2:stop # pm2 stop ecosystem.config.js\npnpm pm2:restart # pm2 restart ecosystem.config.js\npnpm pm2:log # pm2 log ecosystem.config.js\n```\n\n.env.example 复制一份重命名为 .env\n填入自己 bot 的环境变量\n\n```bash\nBOT_TOKEN=                  # TG 机器人token\nADMIN_CHAT_ID=[]              # 管理员的 Chat ID 数组，可添加多个管理员，管理员可执行post操作\nADMIN_USERNAME=@YourUsername    # admin username 别人投稿的时候艾特\nDATABASE_URL=\"file:./data.db\" # 不用改 ｜ 目前是使用 SQLite 的话就是 \"file:./data.db\" 在 prisma/data.db 下 用别的数据库的话就得改改 provider 之类的了日后再说了\n\nENABLE_S3_BACKUP=false      # 是否启用 S3 备份数据库 否则下面这些都忽略\nAWS_ACCESS_KEY_ID=          # S3 access key\nAWS_SECRET_ACCESS_KEY=      # S3 secret key\nS3_BUCKET_NAME=             # S3 bucket name\nS3_ENDPOINT=                # S3 endpoint\nS3_PUBLIC_URL=                 # S3 Public URL\n# 备份文件前缀路径 s3Path = `${S3_PUBLIC_URL}/${BACKUP_FILE_PREFIX || ''}data.db`\nBACKUP_FILE_PREFIX=\"backup/tg-bot-backup/cos-tg-bot-\"      # 备份文件前缀\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusixian%2Fcos-tg-bot-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusixian%2Fcos-tg-bot-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusixian%2Fcos-tg-bot-template/lists"}