Another Pokémon Showdown! bot, this time in Go. Written by TalkTakesTime as a learning exercise.
This bot runs on Go, Google's open-source language, and was developed for version 1.4.2, although it has not been tested on any other versions.
It requires the following packages to run:
encoding/json
-- for logging inerrors
-- for custom errorsflag
-- for command line argumentsgithub.com/TalkTakesTime/hookserve
-- for GitHub webhooksgithub.com/tonnerre/golang-pretty
-- for pretty printinggolang.org/x/net/websocket
-- for websocketsgopkg.in/yaml.v2
-- for parsing the configio/ioutil
-- for reading files and http responseslog
-- for loggingnet/http
-- for logging innet/url
-- for logging inos
-- for dealing with log filesregexp
-- for the PS standard toId functionstrconv
-- for converting betweenint
andstring
strings
-- for message parsingtime
-- for sleeping etc
I will assume that you know how to clone a Git repository or otherwise obtain
the source code (hint: go get github.com/TalkTakesTime/gobot
works). To
install the dependencies, navigate to the directory you downloaded this
repository to, and run
go get .
go build
To build and start the bot, run
cd main
go build
./main
If you want to give the executable a custom name, use
go build -o name
and if you would like it to log to a file filename.log
rather than to
stdout
, use
./main -log=filename.log
To log to a file whose name is the current date, use
./main -log=$(date -Iseconds).log
From there, you're on your own! However, one final warning: the bot will panic
if the port chosen for config.HookPort
is already in use, so choose carefully.
GoBot is distributed under the terms of the MIT License.