From 0003a82421c7146cec2fa266dd4012c1dcce1e4a Mon Sep 17 00:00:00 2001 From: Nikica Jokic Date: Thu, 11 Apr 2013 02:05:49 +0200 Subject: [PATCH 1/3] Updated README.md --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dad4d2a..d1e751d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Detailed information about using Ponder can be found in the [Project Wiki](https ### Usage -#### Setting up the Thaum +#### Setting up ```ruby require 'ponder' @@ -28,16 +28,31 @@ require 'ponder' config.port = 6667 end ``` -#### Add Event Handling +#### Event handling ```ruby @thaum.on :connect do @thaum.join '#ponder' end +# Echo the message back to the channel @thaum.on :channel, /foo/ do |event_data| @thaum.message event_data[:channel], 'bar!' end ``` +#### User tracking +```ruby +# Print a nickname of the joined user +@thaum.on :join do |data| + user = data[:join].user + puts "User joined #{user.nick}" +end + +# Print a nickname of the parted user +@thaum.on :part do |data| + user = data[:part].user + puts "User parted #{user.nick}" +end +``` #### Starting the Thaum ```ruby @thaum.connect From 993a45118de97b287e8e42e8f5cca3773fd484ea Mon Sep 17 00:00:00 2001 From: Nikica Jokic Date: Thu, 11 Apr 2013 02:07:01 +0200 Subject: [PATCH 2/3] Readme update. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1e751d..15706e0 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,13 @@ end ``` #### User tracking ```ruby -# Print a nickname of the joined user +# Print the joined user's nickname @thaum.on :join do |data| user = data[:join].user puts "User joined #{user.nick}" end -# Print a nickname of the parted user +# Print the parted user's nickname @thaum.on :part do |data| user = data[:part].user puts "User parted #{user.nick}" From 46b0b8d586d382a6557ec4fd5c18208e92bdbdd1 Mon Sep 17 00:00:00 2001 From: Nikica Jokic Date: Thu, 11 Apr 2013 02:12:21 +0200 Subject: [PATCH 3/3] Some more clarifications (README.md) --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 15706e0..65714bc 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,16 @@ end ``` #### Event handling ```ruby +# Join a channel when connected @thaum.on :connect do @thaum.join '#ponder' end -# Echo the message back to the channel +# Echo messages matching /foo/ back to the channel @thaum.on :channel, /foo/ do |event_data| @thaum.message event_data[:channel], 'bar!' end -``` -#### User tracking -```ruby + # Print the joined user's nickname @thaum.on :join do |data| user = data[:join].user