mirror of https://github.com/velour/catbase.git
gpt: make gpt the catchall
This commit is contained in:
parent
4626d0270c
commit
d1986be68a
|
@ -151,7 +151,27 @@ func (d *Discord) sendMessage(channel, message string, meMessage bool, args ...a
|
||||||
Interface("data", data).
|
Interface("data", data).
|
||||||
Msg("sending message")
|
Msg("sending message")
|
||||||
|
|
||||||
st, err := d.client.ChannelMessageSendComplex(channel, data)
|
maxLen := 2000
|
||||||
|
chunkSize := maxLen - 100
|
||||||
|
var st *discordgo.Message
|
||||||
|
var err error
|
||||||
|
if len(data.Content) > maxLen {
|
||||||
|
tmp := data.Content
|
||||||
|
data.Content = tmp[:chunkSize]
|
||||||
|
st, err = d.client.ChannelMessageSendComplex(channel, data)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
for i := chunkSize; i < len(data.Content); i += chunkSize {
|
||||||
|
data := &discordgo.MessageSend{Content: tmp[i : i+chunkSize]}
|
||||||
|
st, err = d.client.ChannelMessageSendComplex(channel, data)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
st, err = d.client.ChannelMessageSendComplex(channel, data)
|
||||||
|
}
|
||||||
|
|
||||||
//st, err := d.client.ChannelMessageSend(channel, message)
|
//st, err := d.client.ChannelMessageSend(channel, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
4
main.go
4
main.go
|
@ -135,7 +135,6 @@ func main() {
|
||||||
b.AddPlugin(roles.New(b))
|
b.AddPlugin(roles.New(b))
|
||||||
b.AddPlugin(twitch.New(b))
|
b.AddPlugin(twitch.New(b))
|
||||||
b.AddPlugin(pagecomment.New(b))
|
b.AddPlugin(pagecomment.New(b))
|
||||||
b.AddPlugin(gpt.New(b))
|
|
||||||
b.AddPlugin(secrets.New(b))
|
b.AddPlugin(secrets.New(b))
|
||||||
b.AddPlugin(mayi.New(b))
|
b.AddPlugin(mayi.New(b))
|
||||||
b.AddPlugin(giphy.New(b))
|
b.AddPlugin(giphy.New(b))
|
||||||
|
@ -179,8 +178,9 @@ func main() {
|
||||||
b.AddPlugin(cowboy.New(b))
|
b.AddPlugin(cowboy.New(b))
|
||||||
b.AddPlugin(topic.New(b))
|
b.AddPlugin(topic.New(b))
|
||||||
b.AddPlugin(talker.New(b))
|
b.AddPlugin(talker.New(b))
|
||||||
// catches anything left, will always return true
|
|
||||||
b.AddPlugin(fact.New(b))
|
b.AddPlugin(fact.New(b))
|
||||||
|
// catches anything left, will always return true
|
||||||
|
b.AddPlugin(gpt.New(b))
|
||||||
|
|
||||||
if err := client.Serve(); err != nil {
|
if err := client.Serve(); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err)
|
||||||
|
|
|
@ -485,18 +485,7 @@ func (p *FactoidPlugin) register() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
notFound := p.c.GetArray("fact.notfound", []string{
|
return false
|
||||||
"I don't know.",
|
|
||||||
"NONONONO",
|
|
||||||
"((",
|
|
||||||
"*pukes*",
|
|
||||||
"NOPE! NOPE! NOPE!",
|
|
||||||
"One time, I learned how to jump rope.",
|
|
||||||
})
|
|
||||||
|
|
||||||
// We didn't find anything, panic!
|
|
||||||
p.b.Send(c, bot.Message, message.Channel, notFound[rand.Intn(len(notFound))])
|
|
||||||
return true
|
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
p.b.RegisterTable(p, p.handlers)
|
p.b.RegisterTable(p, p.handlers)
|
||||||
|
|
|
@ -54,6 +54,11 @@ func (p *GPTPlugin) register() {
|
||||||
HelpText: "set the ChatGPT prompt",
|
HelpText: "set the ChatGPT prompt",
|
||||||
Handler: p.setPromptMessage,
|
Handler: p.setPromptMessage,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Kind: bot.Message, IsCmd: true,
|
||||||
|
Regex: regexp.MustCompile(`(?P<text>.*)`),
|
||||||
|
Handler: p.chatMessage,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
log.Debug().Msg("Registering GPT3 handlers")
|
log.Debug().Msg("Registering GPT3 handlers")
|
||||||
p.b.RegisterTable(p, p.h)
|
p.b.RegisterTable(p, p.h)
|
||||||
|
|
Loading…
Reference in New Issue