An open API service indexing awesome lists of open source software.

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

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
}

```