https://github.com/hashimthearab/wolframgo
A simple library to interact with the WolframAlpha API
https://github.com/hashimthearab/wolframgo
ai go golang hacktoberfest wolframalpha
Last synced: about 1 year ago
JSON representation
A simple library to interact with the WolframAlpha API
- Host: GitHub
- URL: https://github.com/hashimthearab/wolframgo
- Owner: HashimTheArab
- License: gpl-3.0
- Created: 2020-12-30T12:56:31.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-28T03:29:53.000Z (over 4 years ago)
- Last Synced: 2025-02-12T23:34:32.111Z (over 1 year ago)
- Topics: ai, go, golang, hacktoberfest, wolframalpha
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WolframGo
A simple lib for WolframAlpha made in Go.
install it with go get github.com/Prim69/WolframGo
## Example
```go
package main
import (
"fmt"
"github.com/prim69/wolframgo"
)
func main() {
wolframgo.SetAppId("Your App ID")
res, err := wolframgo.GetSimpleResult("How many calories are in cereal?")
if err != nil {
panic(err)
}
fmt.Println(res)
}
```
## Example with a discord bot
```go
package main
import (
"github.com/Jviguy/SpeedyCmds/command/ctx"
"github.com/bwmarrin/discordgo"
"github.com/prim69/wolframgo"
"strings"
"fmt"
)
type Ask struct {
}
func (p Ask) Execute(ctx ctx.Ctx, session *discordgo.Session) error {
args := strings.Split(ctx.GetMessage().Content, " ")
if len(args) < 2 {
_, _ = session.ChannelMessageSend(ctx.GetChannel().ID, "Ask me something.")
} else {
wolframgo.SetAppId("Your App ID")
args := args[1:]
question := strings.Join(args, " ")
res, err := wolframgo.GetSimpleResult("How many calories are in cereal?")
if err != nil {
_, _ := session.ChannelMessageSend(ctx.GetChannel().ID, "An error occured: " + err.Error())
}
content := discordgo.MessageSend{
Content: res,
AllowedMentions: &discordgo.MessageAllowedMentions{},
}
_, err = session.ChannelMessageSendComplex(ctx.GetChannel().ID, &content)
return err
}
return nil
}
```