Skip to content

Commit

Permalink
Merge pull request #36 from neektza/master
Browse files Browse the repository at this point in the history
Added a few examples and clarified existing ones (in Readme.md)
  • Loading branch information
tbuehlmann committed Apr 12, 2013
2 parents e6855c2 + 46b0b8d commit edbaea3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Expand Up @@ -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'

Expand All @@ -28,15 +28,29 @@ require 'ponder'
config.port = 6667
end
```
#### Add Event Handling
#### Event handling
```ruby
# Join a channel when connected
@thaum.on :connect do
@thaum.join '#ponder'
end

# Echo messages matching /foo/ back to the channel
@thaum.on :channel, /foo/ do |event_data|
@thaum.message event_data[:channel], 'bar!'
end

# Print the joined user's nickname
@thaum.on :join do |data|
user = data[:join].user
puts "User joined #{user.nick}"
end

# Print the parted user's nickname
@thaum.on :part do |data|
user = data[:part].user
puts "User parted #{user.nick}"
end
```
#### Starting the Thaum
```ruby
Expand Down

0 comments on commit edbaea3

Please sign in to comment.