Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Jun 27, 2012
0 parents commit 7e58b8f
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
*.yaml
!example_config.yaml
Gemfile.lock
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

#ruby=1.9.3
#ruby-gemset=cinch

gemspec
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SMF Bot

IRC bot engine build for `#smf.sh` and related channels, quite similar to [cinchize](https://github.com/netfeed/cinchize).

# Example

`Gemfile`:

source "https://rubygems.org"
#ruby=1.9.3
#ruby-gemset=cinch
gem "cinch-identify"
gem "cinch-yaml-memo"
gem "cinch-url-scraper"

`config.yaml`:

---
server: irc.freenode.net
port: 6667
nick: user
channels:
- "#my-test-channel"
plugins:
"Cinch::Plugins::Identify":
type: :nickserv
username: "user"
password: "password"
"Cinch::Plugins::YamlMemo": nil
"Cinch::Plugins::UrlScraper": nil

and run:

smfbot

# Backup

Do not forget to backup directory in which bot is running.
5 changes: 5 additions & 0 deletions bin/smfbot
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require "smfbot"

SmfBot.new(ARGV).start
6 changes: 6 additions & 0 deletions example/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"
#ruby=1.9.3
#ruby-gemset=cinch
gem "cinch-identify"
gem "cinch-yaml-memo"
gem "cinch-url-scraper"
40 changes: 40 additions & 0 deletions lib/smfbot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require "cinch"
require "yaml"

class SmfBot
def initialize(params)
if File.exist?('config.yaml')
settings = YAML.load_file('config.yaml')||{}
else
raise "\n\n Missing configuration file 'config.yaml'.\n\n"
end
@bot = Cinch::Bot.new do
debug "settings <<-EOF\n#{settings.to_yaml}EOF"
configure do |c|
c.server = settings['server']
c.port = settings['port']
c.channels = settings['channels']
c.nick = settings['nick']
c.username = settings['nick']
c.plugins.plugins = []
end
end
(settings['plugins'] || []).each{ |plugin, options| add_plugin(plugin, options) }
end

def add_plugin(plugin, options = nil)
@bot.info "loading plugin: #{plugin}."
@bot.configure do |c|
require plugin.downcase.gsub('::','/')
plugin = eval plugin
c.plugins.plugins << plugin
c.plugins.options[plugin] = options if options
end
rescue
@bot.warn "failed loading plugin: #{plugin} ->\n#{}"
end

def start
@bot.start
end
end
13 changes: 13 additions & 0 deletions smfbot.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Gem::Specification.new do |s|
s.name = 'smfbot'
s.version = '1.0.0'
s.summary =
s.description = 'IRC bot engine build for #smf.sh and related channels.'
s.authors = ['Michal Papis']
s.email = ['[email protected]']
s.homepage = 'https://github.com/mpapis/smfbot'
s.files = Dir['LICENSE', 'README.md', 'lib/**/*', 'bin/*']
s.executables = ['smfbot']
s.required_ruby_version = '>= 1.9.1'
s.add_dependency("cinch", "~>2")
end
3 changes: 3 additions & 0 deletions smfbot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -Ilib/ bin/smfbot "$@"

0 comments on commit 7e58b8f

Please sign in to comment.