Closed z404 closed 2 years ago
@z404 Please assign me this issue!
@z404 this somehow doesn't seem to work as in the bot doesn't respond with any result. Am I doing something wrong? The app id is functioning properly.
var mathProb = strings.SplitN(m.Content, " ", 2)[1]
c := &wolfram.Client{AppID: os.Getenv("WOLFRAM_API_KEY")}
res, err := c.GetQueryResult(mathProb, nil)
if err != nil {
panic(err)
}
// Iterate through the pods and subpods
// and print out their title attributes
for i := range res.Pods {
s.ChannelMessageSend(m.ChannelID, res.Pods[i].Title)
for j := range res.Pods[i].SubPods {
s.ChannelMessageSend(m.ChannelID, res.Pods[i].SubPods[j].Title)
}
}`
I'm assigning you to this issue!
I'm afk at the moment, I will test the API on my end and put up a post here when I have an update!
@z404 sure!
As is seen with most outdated APIs, this one is very broken.
I'm trying to get this to work directly using the API endpoint, as I did here: #31. I'll add a comment once that works.
@z404 I got the exact same output with this. Definitely broken. However I found another work around with the GetSpokentAnswerQuery function and this seems to work just fine.
res, err := c.GetSpokentAnswerQuery(mathProb, wolfram.Metric, 1000)
if err != nil {
panic(err)
}
s.ChannelMessageSend(m.ChannelID, res)
Nice! This works perfectly, though the output seems a little odd (as it is meant to be spoken, not shown as text). We can work with this for now, and if need be, correct it later. Proceed with using this work-around. Good job :D
@z404 yeah the output is a bit weird but def works! Since the search applies for generic queries as well, should we name the call the command !math or something else maybe?
If you have a better name in mind, feel free to change it!
@z404 alright thanks!
Add a command
!math <math problem>
. When the user executes this command, the bot must make a request to the WolframAlpha API using this package. The reply contains a set of "pods". Sort through these pods and return those that are useful for answering the question.You may take a look at the website here