Skip to content

Instantly share code, notes, and snippets.

@mseymour
Created January 12, 2013 08:44
Show Gist options
  • Save mseymour/4516798 to your computer and use it in GitHub Desktop.
Save mseymour/4516798 to your computer and use it in GitHub Desktop.
Trying to come up with plugin layout ideas for my own IRC framework... I am too biased right now, so everything is very similar to Cinch.
module Sussex
module Plugins
# This is just a class for laying out possible plugin ideas.
# I have been using Cinch for about a year and a half now, so I am quite
# biased in terms of plugin design for something like this...
# Note that I also use an include for including methods/etc. into the plugin
# There are probably other ways of doing this as well.
class MyPlugin
include Sussex::Plugin
# Idea 1: iDSL 'on' method.
# Very similar to Cinch, and using Dominikh's idea for writing plugins
# with DSL methods rather than separate 'match', 'listen', etc. methods at
# some point.
on :match, /hello, (.+)/ do |m, string|
if string.eql? @bot.nick
m.reply "Hello to you too, #{m.nick}!"
end
end
# Idea 2: Separate method call/definition
# Again, quite a bit similar^W^W^W^Wcopying Cinch.
# Maybe I should look into different concepts other than what Cinch has...
match /hello, (.+)/, method: :hello
def hello(m, string)
if string.eql? @bot.nick
m.reply "Hello to you too, #{m.nick}!"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment