From 61add2ce3d9b7b8bda68daa5efea7c303ae9e4b0 Mon Sep 17 00:00:00 2001 From: Ayomide Onigbinde Date: Wed, 2 Jan 2019 20:12:05 +0100 Subject: [PATCH] reverted PR 51; fixed persistent menu typo --- examples/basic/bot.config.yml | 5 ---- examples/basic/main.go | 10 ++++---- messenger.go | 2 +- parser.go | 45 ----------------------------------- 4 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 examples/basic/bot.config.yml delete mode 100644 parser.go diff --git a/examples/basic/bot.config.yml b/examples/basic/bot.config.yml deleted file mode 100644 index f867ca7..0000000 --- a/examples/basic/bot.config.yml +++ /dev/null @@ -1,5 +0,0 @@ -verify_token: -access_token: -app_secret: - -# other configs can be added as necessary. For example, the webhook URL and host. diff --git a/examples/basic/main.go b/examples/basic/main.go index e17bc37..f86d6e0 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -7,17 +7,17 @@ import ( "net/http" "os" "time" + "github.com/paked/messenger" ) -var vt, acct, appsc = messenger.GetTokens() var ( - verifyToken = flag.String("verify-token", vt, "The token used to verify facebook (required)") + verifyToken = flag.String("verify-token", "mad-skrilla", "The token used to verify facebook (required)") verify = flag.Bool("should-verify", false, "Whether or not the app should verify itself") - pageToken = flag.String("page-token", acct, "The token that is used to verify the page on facebook") - appSecret = flag.String("app-secret", appsc, "The app secret from the facebook developer portal (required)") + pageToken = flag.String("page-token", "not skrilla", "The token that is used to verify the page on facebook") + appSecret = flag.String("app-secret", "", "The app secret from the facebook developer portal (required)") host = flag.String("host", "localhost", "The host used to serve the messenger bot") - port = flag.Int("port", 5000, "The port used to serve the messenger bot") + port = flag.Int("port", 8080, "The port used to serve the messenger bot") ) func main() { diff --git a/messenger.go b/messenger.go index 4bde940..251c240 100644 --- a/messenger.go +++ b/messenger.go @@ -240,7 +240,7 @@ func (m *Messenger) GreetingSetting(text string) error { return checkFacebookError(resp.Body) } -// CallToActionsSetting sends settings for Get Started or Persist Menu +// CallToActionsSetting sends settings for Get Started or Persistent Menu func (m *Messenger) CallToActionsSetting(state string, actions []CallToActionsItem) error { d := CallToActionsSetting{ SettingType: "call_to_actions", diff --git a/parser.go b/parser.go deleted file mode 100644 index 9d8c52d..0000000 --- a/parser.go +++ /dev/null @@ -1,45 +0,0 @@ -package messenger - -import ( - "io/ioutil" - "log" - "os" - "path/filepath" - - "gopkg.in/yaml.v2" -) - -//Config is the struct for the configuration file -type Config struct { - VerifyToken string `yaml:"verify_token"` - AccessToken string `yaml:"access_token"` - AppSecret string `yaml:"app_secret"` -} - -//ReadYml parses the config yml file and format into the Config struct -func (x *Config) ReadYml() *Config { - configFile, err := filepath.Abs("./bot.config.yml") - if err != nil { - log.Printf("ERROR READING THE CONFIG FILE: %s", err) - } - - yamlFile, err := ioutil.ReadFile(configFile) - - if err != nil { - log.Println("Could not find the config file. Please make sure it is created", err) - os.Exit(-1) - } - - yaml.Unmarshal(yamlFile, &x) - - return x -} - -//GetTokens returns the verifytoken, accesstoken and the appsecret from the config file -func GetTokens() (string, string, string) { - var c Config - - configObj := c.ReadYml() - verifyToken, accessToken, appSecret := configObj.VerifyToken, configObj.AccessToken, configObj.AppSecret - return verifyToken, accessToken, appSecret -}