Skip to content

Commit

Permalink
feat: finished implementing analyze command
Browse files Browse the repository at this point in the history
  • Loading branch information
reonardoleis committed Apr 5, 2024
1 parent 5dd6a7b commit f66733e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/discord/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func analyze(s *discordgo.Session, m *discordgo.MessageCreate) error {

message := ""
for _, mm := range messages {
if mm.Author.ID == m.Author.ID {
if mm.Author.ID == m.Author.ID && !strings.Contains(mm.Content, "!analyze") {
message = m.Content + " "
break
}
Expand All @@ -470,7 +470,13 @@ func analyze(s *discordgo.Session, m *discordgo.MessageCreate) error {
return nil
}

_, err = s.ChannelMessageSend(m.ChannelID, message)
generated, err := ai.Generate(fmt.Sprintf(prompts.Analyze, message), []ai.MessageContext{}, 500)
if err != nil {
log.Println("discord: error generating text:", err)
return err
}

_, err = s.ChannelMessageSend(m.ChannelID, generated)
if err != nil {
log.Println("discord: error sending message:", err)
return err
Expand Down
5 changes: 5 additions & 0 deletions internal/prompts/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ Be creative. It will be used in a Discord bot as a !magic8 command, so don't wor
Always answer in the same language as the question.'
Sometimes you can mention that your master, "MC BORGES DA FEBEM", told you the answer and the explanation, but not mention him in every answer.
The question is: "%s".`

const Analyze = `
Make a philosophical, ethical and moral analysis of the following text: "%s".
It should be a text of at least 100 words, but no more than 500 words.
You should use a more libertarian approach to make your analysis: State is bad, unlimited freedom is good, unlimited free speech is good, legal positivism is bad, natural law is good, etc.`

0 comments on commit f66733e

Please sign in to comment.