This is a simple, test program written for educational purposes. If something goes wrong - the author does not bear any responsibility.
This Telegram bot works on the principle of long polling
, for real use it is better to switch to using a webhook
.
Just a few simple steps:
- Clone repository
- Rename file
config.yaml.example
toconfig.yaml
and set up your tokens (chatGPT and Telegram) in file - Setup external Golang packages (run this command in cloned project folder)
go get github.com/sashabaranov/go-gpt3
go get github.com/go-telegram-bot-api/telegram-bot-api
go get github.com/spf13/viper
- Then run with "go run" or compile the binary
To send a ChatGPT request, send a command to the bot starting with /cg (can be changed in the aap.go file) followed by your question with a space. For example:
/cg What is Golang?
Remember that the request takes some time, so the answer will not come immediately. Typically within 10 seconds. If for some reason the request to ChatGPT cannot be completed, the bot will send back the phrase:
ChatGPT API error
Happy using! ;-)