Skip to content

Commit

Permalink
wip: debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
fanhousanbu committed Mar 16, 2024
1 parent 3d34516 commit f392ca7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
runtime/
.env
dist/
config.toml
config.*.toml
db/geecaptcha.db
captcha-bot
dict/dec_*
dict/dec_*
.vscode
30 changes: 30 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#系统设置
[system]
app_debbug=false
join_hint_after_del_time=60 # 加群验证提示消息多久删除,秒
captcha_timeout=120 # 验证超时时间,秒
runtime_path="/runtime" # 缓存目录

#telegram 配置
[telegram]
bot_token="" # 机器人apitoken
api_proxy="" # telegram api代理,仅大陆地区服务器需要
manage_users=[] # 超级管理员userid数组,以英文逗号分割,例如123,456,789

#日志配置
[log]
max_size=32
max_age=7
max_backups=3

#消息模板
[message]
join_hint="欢迎 [%s](%s) 加入 %s\n ⚠️本群已开启新成员验证功能,未通过验证的用户无法发言 \n超时未完成验证会被移除本群! \n⏱本条消息 %d 秒后自动删除\n👇点击下方按钮自助解除禁言"
captcha_image="欢迎您加入[%s]!\n⚠本群已开启新成员验证功能。\n👆为了证明您不是机器人,请发送以上图片验证码内容\n🤖机器人将自动验证您发送的验证码内容是否正确\n⏱本条验证消息有效期[%d]秒"
verification_complete="恭喜您成功通过[🤖人机验证],系统已为您解除禁言限制。\n如若还是无法发言,请重启telegram客户端\n请同时注意群内发言规范,以防永久禁止"
block_hint="\\#封禁预警\n[%s](%s) 请注意,您的消息中含有部分违禁词 \n⚠️您已被系统判断为高风险用户,已被封禁\n系统已向超管发送预警信息,若由超管判定为误杀,会及时将您解除封禁。\n您的违禁词包含:%s"

#广告阻止
[adblock]
number_of_forbidden_words=2 # 违禁词判定个数,如果一句话中出现的违禁词为该设置个数,则判断为违禁
block_time=-1 # 阻止时间,单位:秒。如果为-1,则代表永久封禁
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package main

import (
"fmt"
"net/http"

"github.com/assimon/captcha-bot/bootstrap"
)

func main() {
go func() {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "OK")
})
http.ListenAndServe(":8080", nil)
}()

bootstrap.Start()
}
9 changes: 7 additions & 2 deletions util/config/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package config

import (
"github.com/spf13/viper"
"log"
"os"

"github.com/spf13/viper"
)

var AppPath string
Expand Down Expand Up @@ -55,7 +56,11 @@ func InitConfig() {
log.Fatal(err)
}
AppPath = path
viper.SetConfigFile(path + "/config/config.toml")
if os.Getenv("Env") == "dev" {
viper.SetConfigFile(path + "/config/config.dev.toml")
} else {
viper.SetConfigFile(path + "/config/config.toml")
}
err = viper.ReadInConfig()
if err != nil {
log.Fatal("load config file err:", err)
Expand Down

0 comments on commit f392ca7

Please sign in to comment.