Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bighu630/tg_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
ivhu committed Dec 3, 2024
2 parents 8412c95 + 6166157 commit 3f039a6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,46 @@

chatgpt待续...

## 使用教程
## 使用教程(tg用户)

群互动机器人

用法:

cp语录:

1. 引用其他人的消息
2. 回复关键词 [mua,mua~,摸摸,抱抱]
3. 有60%概率触发,摘星会引用你引用的话,并发🍬
骂人:

1. 引用其他人的消息
2. 回复 [骂他,咬他],其中 他 可以替换为 她 它 ta
3. 100%触发,摘星会引用你引用而话,并骂他
chatgpt:

1. 在群聊中使用 `/chat msg` 可以与摘星聊天,MSG可以是任意内容
2. 在群聊里引用摘星的话,摘星会以为你在和他聊天,@则不会
3. 私聊摘星,摘星会与你对话
youtubeMusic下载:

私聊或者群聊里发送youtubeMusic链接,摘星会下载音乐并唱给你听
> 摘星是bot的名字:@ytbmusicPlaerBot
另外你们的start是作者最大的动力😀


## 使用教程(服务端)

修改config copy.toml为config.toml

Expand Down
4 changes: 4 additions & 0 deletions ai/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (g *gemini) Chat(chatId string, msg string) (string, error) {
cs = g.model.StartChat()
g.chats[chatId] = cs
}
if len(cs.History) > 30 {
cs.History = cs.History[len(cs.History)-30:]
}
if err := g.db.Add(models.NewChat(chatId, true, msg)); err != nil {
log.Error().Err(err).Msg("failed to add chat record")
}
Expand All @@ -104,6 +107,7 @@ func (g *gemini) Chat(chatId string, msg string) (string, error) {
result := fmt.Sprint(resp.Candidates[0].Content.Parts[0])
if err := g.db.Add(models.NewChat(chatId, false, result)); err != nil {
log.Error().Err(err).Msg("failed to add chat record")
return "", err
}
return result, nil
}
Expand Down
1 change: 1 addition & 0 deletions handler/gemini_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func handlePrivateChat(b *gotgbot.Bot, ctx *ext.Context, ai ai.AiInterface) erro
if err != nil {
log.Error().Err(err).Msg("gemini chat error")
ctx.EffectiveMessage.Reply(b, "gemini chat error", nil)
a <- struct{}{}
return err
}
log.Debug().Msgf("%s say: %s", sender, input)
Expand Down
3 changes: 2 additions & 1 deletion handler/quotation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var quotationsKey = map[string]string{
"抱抱~": couple,
"亲亲~": couple,
"贴贴~": couple,
"rua": couple,
}

type quotationsHandler struct {
Expand Down Expand Up @@ -104,7 +105,7 @@ func (y *quotationsHandler) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool {
crossR = true
}
if crossR {
return getRandomProbability(0.6)
return getRandomProbability(0.75)
}
return false
}
Expand Down

0 comments on commit 3f039a6

Please sign in to comment.