yetibot / yetibot

🤖 Extreme chatops bot for Slack, Discord, Mattermost, IRC 🔧 New contributors welcome 🏗
https://yetibot.com
Eclipse Public License 1.0
349 stars 62 forks source link

twitter show <username> #564

Closed devth closed 8 years ago

devth commented 8 years ago

Show the top 10 tweets for username. Maybe include options to exclude retweets and replies. Related: #552

dev-hartmann commented 8 years ago

Hey there, I'm new to Clojure and would like to tackle this issue. I guess at some point I will be asking a few questions ;)

devth commented 8 years ago

Awesome, feel free to ask anytime!

devth commented 8 years ago

Here's a few suggestions to get started.

You'll want to add a subcommand regex after this line: https://github.com/devth/yetibot/blob/db13cd00f3f84e0d69e40cf9e1144bb1e6d4263d/src/yetibot/commands/twitter.clj#L87

Something like:

#"^show\s+(\S+)" show

That will send all twitter show <username> commands to a show function, which will look something like:

(defn show
  "twitter show <screen-name> # show the top 10 tweets from <screen-name>"
  [{[_ screen-name] :match}]
    ;; TODO, use the twitter `model` to do get results from twitter api
  )

Command handlers (such as show and lookup) get a map of args including things like the matched regex, raw args, user, etc. We're only interested in :match here - it contains the result of applying re-find to your regex and the string. For example:

yetibot.core.repl=> (re-find #"show\s+(\S+)" "show yetibot")
["show yetibot" "yetibot"]

Since the first item in the vector is the full string, we ignore it and destructure the 2nd item into screen-name: {[_ screen-name] :match}.

Ping me if you need to!

dev-hartmann commented 8 years ago

Thanks for providing the awesome hints! Will start working on it this evening after work.

manalipankaj commented 8 years ago

Can we still contribute?

dev-hartmann commented 8 years ago

hey, i got a basic implementation done. i will push to my fork this evening after work. maybe you want to have a look and help me get this done? i'm still new to clojure, so there will be enough space for improvements.

dev-hartmann commented 8 years ago

I had the repo on my work machine, so I could send a PR. Please have a look at the code

https://github.com/devth/yetibot/pull/569

devth commented 8 years ago

@dev-hartmann responded on your PR.

@manalipankaj yep, you're welcome to contribute!

devth commented 8 years ago

Fixed by #569