MCPcopy Index your code
hub / github.com/amyouran/v2board-telegram-bot

github.com/amyouran/v2board-telegram-bot @v1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.1 ↗ · + Follow
306 symbols 535 edges 32 files 58 documented · 19% updated 2y agov1.0.1 · 2024-05-09★ 37
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

v2board-telegram-bot

高性能、高负载、部署简单, 基于Golang实现了原版Bot的功能,并增加了群组签到随机赠送流量。

Go version 1.22.0 Custom Badge Telegram

介绍

根据互联网上的普遍论调,golangphp快5至25倍。由此推论,这个Bot比原版Bot快5至25倍。值得注意的是:在签到模块,本Bot使用了Redis缓存,这将进一步拉大两者之间的性能差距。 另一个值得称道的小细节是:本Bot向Telegram注册了自己的命令,在群组或私聊中输入/即可获得Bot可用命令的提示,这在原版Bot中似乎也是没有的。

image

测试Bot

配置 Config.yaml

Field Desc
Token bot的token
PublicURL webhook的地址
ListenPort Bot监听的端口
Secret 验证请求是否来自Tg的密匙
CustomPrefixPrompts 自定义报错返回前缀
Max 签到最高奖励流量(Byte)
Min 签到最低奖励流量(Byte)

A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

在每个 Webhook 请求中,应该发送一个秘密令牌到头部“X-Telegram-Bot-Api-Secret-Token”,长度为 1-256 个字符。只允许使用字母 A-Z、a-z、数字 0-9、下划线(_)和连字符(-)。这个头部很有用,可以确保请求来自由你设置的 Webhook。

关于 CustomPrefixPrompts: 一个有趣的设置,Bot会随机挑选列表中的一个前缀来使用。

使用方法(aapanel部署)

  1. 创建数据库表, 进入v2board面板数据库, 执行以下命令:
DROP 
  TABLE IF EXISTS `v2_telegram_checkin`;
CREATE TABLE `v2_telegram_checkin` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 
  `user_tg_id` BIGINT(20) NOT NULL COMMENT '用户TGID',
  `user_id` int(11) unsigned NOT NULL COMMENT '用户id',  
  `award`   BIGINT(20) NOT NULL COMMENT '奖励流量', 
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 
  PRIMARY KEY (`id`), 
  INDEX `idx_user_tg_id` (`user_tg_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '签到记录表';
  1. 下载软件包v1.0.0上传到服务器解压缩
  2. 配置configs目录下的configs.example.yaml,完成后重命名为 configs.yaml

PublicURL 配置为v2board域名/v2boardbot(例如: https://bot.xxxxx.top/v2boardbot), 保证bot.xxxxx.top可以访问v2board面板。 ListenPort 选择一个空闲端口(例如:9996)

  1. 打开v2board面板网站的配置增加反向代理,参考PublicURLListenPort修改成如下所示。 image

  2. 配置后台运行, 按下方说明填写, 填写后点击Confirm添加即可运行。

aaPanel 面板 > App Store > Tools 找到Supervisor进行安装,安装完成后点击设置 > Add Daemon按照如下填写, 在 Name 填写 V2boardbot, 在 Run User 选择 root (有权限的用户即可), 在 Run Dir 选择 软件包上传的目录 , 在 Start Command 填写 软件包上传的目录/main(例如上传到root目录下则是: /root/v2board-telegram-bot/main), 在 Processes 填写 1 。

image

查看Log显示如上则为成功。

推荐

License

MIT

Copyright (c) 2014-present, Linki

Extension points exported contracts — how you extend this code

Meta (Interface)
Meta key-value [1 implementers]
logger/logger.go
Error (Interface)
Error a error with caller stack information [1 implementers]
errors/errors.go
Repo (Interface)
(no doc) [2 implementers]
repository/mysql/mysql.go
Repo (Interface)
(no doc) [2 implementers]
cmd/mysqlmd/mysql/mysql.go
Pipeliner (Interface)
(no doc)
repository/redis/redis.go
BotCommandHandler (FuncType)
(no doc)
bot/handler/handler.go
Option (FuncType)
Option custom setup config
logger/logger.go

Core symbols most depended-on inside this repo

Error
called by 19
errors/errors.go
Get
called by 12
configs/configs.go
NewWithErr
called by 12
errors/errors.go
TrafficConvert
called by 6
utils/utils.go
callers
called by 6
errors/errors.go
GetDb
called by 6
cmd/mysqlmd/mysql/mysql.go
Parse
called by 6
cmd/gormgen/pkg/parser.go
GetDbClient
called by 5
repository/mysql/mysql.go

Shape

Method 207
Function 67
Struct 24
Interface 5
FuncType 2
TypeAlias 1

Languages

Go100%

Modules by API surface

repository/mysql/v2_user/gen_v2_user.go141 symbols
repository/mysql/v2_telegram_checkin/gen_v2_telegram_checkin.go37 symbols
logger/logger.go22 symbols
errors/errors.go13 symbols
repository/mysql/mysql.go12 symbols
cmd/gormgen/pkg/generator.go12 symbols
cmd/mysqlmd/mysql/mysql.go9 symbols
cmd/mysqlmd/main.go9 symbols
utils/timeutil/timeutil.go8 symbols
configs/configs.go7 symbols
cmd/gormgen/pkg/parser.go6 symbols
bot/bot.go4 symbols

For agents

$ claude mcp add v2board-telegram-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page