Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created August 26, 2010 02:43
Show Gist options
  • Save ymendel/550688 to your computer and use it in GitHub Desktop.
Save ymendel/550688 to your computer and use it in GitHub Desktop.
$ rvm use ruby-1.9.1
info: Using ruby 1.9.1 p378
Cassady:~ yossef$ irb
reruby-1.9.1-p378 > require 'rubygems'
=> false
ruby-1.9.1-p378 > require 'cinch'
=> true
ruby-1.9.1-p378 > bot = Cinch::Bot.new
=> #<Cinch::Bot:0x444914 @logger=#<Cinch::Logger::FormattedLogger:0x4448f8 @output=#<IO:<STDERR>>, @mutex=#<Mutex:0x4448dc>>, @events={:connect=>[[[//], [], #<Proc:0x43b438@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/bot.rb:122>]]}, @config=#<OpenStruct server="localhost", port=6667, ssl=false, password=nil, nick="cinch", realname="cinch", verbose=true, messages_per_second=0.5, server_queue_size=10, strictness=:forgiving, message_split_start="... ", message_split_end=" ...", max_messages=nil, plugins=#<OpenStruct plugins=[], prefix="!", options={}>, channels=[], encoding=nil>, @semaphores_mutex=#<Mutex:0x43b4fc>, @semaphores={}, @plugins=[], @callback=#<Cinch::Callback:0x43b48c @bot=#<Cinch::Bot:0x444914 ...>>, @channels=[]>
ruby-1.9.1-p378 > class SomePlugin
ruby-1.9.1-p378 ?> include Cinch::Plugin
ruby-1.9.1-p378 ?> match /heyo/
ruby-1.9.1-p378 ?> end
=> [#<struct Cinch::Plugin::ClassMethods::Pattern pattern=/heyo/, use_prefix=true, method=:execute>]
ruby-1.9.1-p378 > plug = SomePlugin.new(bot)
!! [plugin] someplugin: Registering executor with pattern `(?-mix:^!(?-mix:heyo))`, reacting on `message`
=> #<SomePlugin:0x41f7d4 @bot=#<Cinch::Bot:0x444914 @logger=#<Cinch::Logger::FormattedLogger:0x4448f8 @output=#<IO:<STDERR>>, @mutex=#<Mutex:0x4448dc>>, @events={:connect=>[[[//], [], #<Proc:0x43b438@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/bot.rb:122>]], :message=>[[[/^!(?-mix:heyo)/], [#<SomePlugin:0x41f7d4 ...>, #<struct Cinch::Plugin::ClassMethods::Pattern pattern=/^!(?-mix:heyo)/, use_prefix=true, method=:execute>], #<Proc:0x41f048@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/plugin.rb:130>]]}, @config=#<OpenStruct server="localhost", port=6667, ssl=false, password=nil, nick="cinch", realname="cinch", verbose=true, messages_per_second=0.5, server_queue_size=10, strictness=:forgiving, message_split_start="... ", message_split_end=" ...", max_messages=nil, plugins=#<OpenStruct plugins=[], prefix="!", options={}>, channels=[], encoding=nil>, @semaphores_mutex=#<Mutex:0x43b4fc>, @semaphores={}, @plugins=[], @callback=#<Cinch::Callback:0x43b48c @bot=#<Cinch::Bot:0x444914 ...>>, @channels=[]>>
ruby-1.9.1-p378 > SomePlugin.instance_variable_get('__@cinch_patterns')
NameError: `__@cinch_patterns' is not allowed as an instance variable name
from (irb):9:in `instance_variable_get'
from (irb):9
from /Users/yossef/.rvm/rubies/ruby-1.9.1-p378/bin/irb:17:in `<main>'
ruby-1.9.1-p378 > SomePlugin.instance_variable_get('@__cinch_patterns')
=> [#<struct Cinch::Plugin::ClassMethods::Pattern pattern=/^!(?-mix:heyo)/, use_prefix=true, method=:execute>]
ruby-1.9.1-p378 > plug = SomePlugin.new(bot)
!! [plugin] someplugin: Registering executor with pattern `(?-mix:^!(?-mix:^!(?-mix:heyo)))`, reacting on `message`
=> #<SomePlugin:0x1f8508 @bot=#<Cinch::Bot:0x444914 @logger=#<Cinch::Logger::FormattedLogger:0x4448f8 @output=#<IO:<STDERR>>, @mutex=#<Mutex:0x4448dc>>, @events={:connect=>[[[//], [], #<Proc:0x43b438@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/bot.rb:122>]], :message=>[[[/^!(?-mix:heyo)/], [#<SomePlugin:0x41f7d4 @bot=#<Cinch::Bot:0x444914 ...>>, #<struct Cinch::Plugin::ClassMethods::Pattern pattern=/^!(?-mix:^!(?-mix:heyo))/, use_prefix=true, method=:execute>], #<Proc:0x41f048@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/plugin.rb:130>], [[/^!(?-mix:^!(?-mix:heyo))/], [#<SomePlugin:0x1f8508 ...>, #<struct Cinch::Plugin::ClassMethods::Pattern pattern=/^!(?-mix:^!(?-mix:heyo))/, use_prefix=true, method=:execute>], #<Proc:0x1f2148@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/plugin.rb:130>]]}, @config=#<OpenStruct server="localhost", port=6667, ssl=false, password=nil, nick="cinch", realname="cinch", verbose=true, messages_per_second=0.5, server_queue_size=10, strictness=:forgiving, message_split_start="... ", message_split_end=" ...", max_messages=nil, plugins=#<OpenStruct plugins=[], prefix="!", options={}>, channels=[], encoding=nil>, @semaphores_mutex=#<Mutex:0x43b4fc>, @semaphores={}, @plugins=[], @callback=#<Cinch::Callback:0x43b48c @bot=#<Cinch::Bot:0x444914 ...>>, @channels=[]>>
ruby-1.9.1-p378 > SomePlugin.instance_variable_get('@__cinch_patterns')
=> [#<struct Cinch::Plugin::ClassMethods::Pattern pattern=/^!(?-mix:^!(?-mix:heyo))/, use_prefix=true, method=:execute>]
ruby-1.9.1-p378 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment