-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7e58b8f
Showing
8 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.gem | ||
*.yaml | ||
!example_config.yaml | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "smfbot" | ||
|
||
SmfBot.new(ARGV).start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
ruby -Ilib/ bin/smfbot "$@" |