Skip to content

Commit

Permalink
Added (un)follow for the tumblrbee
Browse files Browse the repository at this point in the history
Added logging on error and implemented follow/unfollow
  • Loading branch information
penguwin committed Feb 19, 2017
1 parent 810e8a2 commit 917b1cc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
26 changes: 24 additions & 2 deletions bees/tumblrbee/tumblrbee.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ func (mod *TumblrBee) Action(action bees.Action) []bees.Placeholder {
action.Options.Bind("text", &text)

state := "published"
mod.client.CreateText(mod.blogname, map[string]string{
err := mod.client.CreateText(mod.blogname, map[string]string{
"body": text,
"state": state})
if err != nil {
mod.LogErrorf("Failed to post text: %v", err)
}

case "post_quote":
quote := ""
Expand All @@ -63,10 +66,29 @@ func (mod *TumblrBee) Action(action bees.Action) []bees.Placeholder {
action.Options.Bind("source", &source)

state := "published"
mod.client.CreateQuote(mod.blogname, map[string]string{
err := mod.client.CreateQuote(mod.blogname, map[string]string{
"quote": quote,
"source": source,
"state": state})
if err != nil {
mod.LogErrorf("Failed to post quote: %v", err)
}

case "follow":
blogname := ""
action.Options.Bind("blogname", &blogname)

if err := mod.client.Follow(blogname); err != nil {
mod.LogErrorf("Failed to follow blog: %v", err)
}

case "unfollow":
blogname := ""
action.Options.Bind("blogname", &blogname)

if err := mod.client.Unfollow(blogname); err != nil {
mod.LogErrorf("Failed to unfollow blog: %v", err)
}

default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
Expand Down
26 changes: 26 additions & 0 deletions bees/tumblrbee/tumblrbeefactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,32 @@ func (factory *TumblrBeeFactory) Actions() []bees.ActionDescriptor {
},
},
},
{
Namespace: factory.Name(),
Name: "follow",
Description: "Follow a blog on Tumblr",
Options: []bees.PlaceholderDescriptor{
{
Name: "blogname",
Description: "Blogname to follow",
Type: "string",
Mandatory: true,
},
},
},
{
Namespace: factory.Name(),
Name: "unfollow",
Description: "Unfollow a blog on Tumblr",
Options: []bees.PlaceholderDescriptor{
{
Name: "blogname",
Description: "Blogname to unfollow",
Type: "string",
Mandatory: true,
},
},
},
}
return actions
}
Expand Down

0 comments on commit 917b1cc

Please sign in to comment.