From: Giuseppe Bilotta Date: Sun, 18 Feb 2007 14:27:43 +0000 (+0000) Subject: Plugin header boilerplating. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=edd1cf77be07ae507014574141e920ad23eb164d;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git Plugin header boilerplating. New plugin.header file provided, to be used as model for the header of new plugins. Many existing plugins have been adjusted to provide the same info the same way. I might have misplaced some information, so please let me know if this is the case. Also augmented a couple of copyright notices to include the 'rbot development team' alongside Tom Gilbert. --- diff --git a/AUTHORS b/AUTHORS index 96e09504..4ed464d4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,7 +2,7 @@ Main Author o Tom Gilbert (giblet) Bugbear (heavy-duty framework reworker and backwards-compatibility-breaker) -o Giuseppe Bilotta (tango_) +o Giuseppe "Oblomov" Bilotta (tango_) Patch contributors o Peter Suschlik (pesu) diff --git a/ChangeLog b/ChangeLog index 5680f0df..fc5beeb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-02-18 Giuseppe Bilotta + + * Plugin: Provide a plugin.header file with boilerplate plugin + title/author/copyright/license information. Authors of new plugins are + encouraged to use it. Many existing plugins have been changed to + follow the same spec. + 2007-02-15 Giuseppe Bilotta * Plugin: new unreplied() method to handle PRIVMSGs which have not diff --git a/data/rbot/plugins/azgame.rb b/data/rbot/plugins/azgame.rb index dab112cd..a6979830 100644 --- a/data/rbot/plugins/azgame.rb +++ b/data/rbot/plugins/azgame.rb @@ -1,11 +1,17 @@ -# vim: set et sw=2: -# A-Z Game: guess the word by reducing the interval of allowed ones +#-- vim:sw=2:et +#++ +# +# :title: A-Z Game Plugin for rbot +# +# Author:: Giuseppe "Oblomov" Bilotta +# Author:: Yaohan Chen : Japanese support # -# Author: Giuseppe "Oblomov" Bilotta -# Author: Yaohan Chen : Japanese support +# Copyright:: (C) 2006 Giuseppe Bilotta +# Copyright:: (C) 2007 GIuseppe Bilotta, Yaohan Chen # -# (C) 2006 Giuseppe Bilotta -# (C) 2007 Yaohan Chen +# License:: GPL v2 +# +# A-Z Game: guess the word by reducing the interval of allowed ones # # TODO allow manual addition of words diff --git a/data/rbot/plugins/bans.rb b/data/rbot/plugins/bans.rb index dfbe116d..17281d4c 100644 --- a/data/rbot/plugins/bans.rb +++ b/data/rbot/plugins/bans.rb @@ -1,10 +1,19 @@ -# BansPlugin v3 for 0.9.11 +#-- vim:sw=2:et +#++ # -# Managing kick and bans, automatically removing bans after timeouts, quiet bans, and kickban/quietban based on regexp +# :title: Bans Plugin v3 for rbot 0.9.11 and later # -# (c) 2006 Marco Gulino -# (c) 2007 kamu -# (c) 2007 Giuseppe Bilotta +# Author:: Marco Gulino +# Author:: kamu +# Author:: Giuseppe Bilotta +# +# Copyright:: (C) 2006 Marco Gulino +# Copyright:: (C) 2007 kamu, Giuseppe Bilotta +# +# License:: GPL V2. +# +# Managing kick and bans, automatically removing bans after timeouts, quiet +# bans, and kickban/quietban based on regexp # # v1 -> v2 (kamu's version, never released) # * reworked @@ -13,15 +22,15 @@ # # v2 -> v3 (GB) # * remove the 'bans' prefix from most of the commands -# * (un)quiet has been renamed to (un)silence because 'quiet' was used to tell the bot to keep quiet +# * (un)quiet has been renamed to (un)silence because 'quiet' was used to +# tell the bot to keep quiet # * both (un)quiet and (un)silence are accepted as actions # * use the more descriptive 'onjoin' term for autoactions -# * convert v1's (0.9.10) :bans and :bansmasks to BadWordActions and WhitelistEntries +# * convert v1's (0.9.10) :bans and :bansmasks to BadWordActions and +# WhitelistEntries # * enhanced list manipulation facilities # * fixed regexp usage in requirements for plugin map # * add proper auth management -# -# Licensed under GPL V2. OnJoinAction = Struct.new("OnJoinAction", :host, :action, :channel, :reason) BadWordAction = Struct.new("BadWordAction", :regexp, :action, :channel, :timer, :reason) diff --git a/data/rbot/plugins/debugger.rb b/data/rbot/plugins/debugger.rb index 2851d6a9..6eabdfea 100644 --- a/data/rbot/plugins/debugger.rb +++ b/data/rbot/plugins/debugger.rb @@ -1,7 +1,11 @@ -# Debugging/profiling for rbot +#-- vim:sw=2:et +#++ # -# (c) 2006 Giuseppe Bilotta -# Licensed under GPL V2. +# :title: Debugging/profiling for rbot +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# License:: GPL v2 class DebugPlugin < Plugin BotConfig.register BotConfigIntegerValue.new('debug.interval', diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb index 4e1bb721..149233d3 100644 --- a/data/rbot/plugins/dict.rb +++ b/data/rbot/plugins/dict.rb @@ -1,16 +1,21 @@ -# vim: set sw=2 et: +#-- vim:sw=2:et +#++ # -# dict plugin: provides a link to the definition of a word in one of the supported +# :title: Dictionary lookup plugin for rbot +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# License:: GPL v2 +# +# Provides a link to the definition of a word in one of the supported # dictionaries. Currently available are # * the Oxford dictionary for (British) English # * the De Mauro/Paravia dictionary for Italian # * the Chambers dictionary for English (accepts both US and UK) # -# other plugins can use this one to check if a given word is valid in italian +# Other plugins can use this one to check if a given word is valid in italian # or english by using the is_italian?/is_british?/is_english? methods # -# Author: Giuseppe "Oblomov" Bilotta -# # TODO: cache results and reuse them if get_cached returns a cache copy require 'uri' diff --git a/data/rbot/plugins/digg.rb b/data/rbot/plugins/digg.rb index 8e3aeb4e..43b7c9f5 100644 --- a/data/rbot/plugins/digg.rb +++ b/data/rbot/plugins/digg.rb @@ -1,4 +1,4 @@ -# Hacked up slashdot headlines plugin... +# Hacked up digg headlines plugin... require 'time' require 'rexml/document' diff --git a/data/rbot/plugins/forecast.rb b/data/rbot/plugins/forecast.rb index 63e3127c..d0847b59 100644 --- a/data/rbot/plugins/forecast.rb +++ b/data/rbot/plugins/forecast.rb @@ -1,8 +1,11 @@ +#-- vim:sw=2:et +#++ # -# Forecast plugin for rbot -# by MrChucho (mrchucho@mrchucho.net) -# Copyright (C) 2006 Ralph M. Churchill +# :title: Forecast plugin for rbot # +# Author:: MrChucho (mrchucho@mrchucho.net) +# Copyright:: (C) 2006 Ralph M. Churchill + require 'soap/wsdlDriver' require 'open-uri' require 'rexml/document' diff --git a/data/rbot/plugins/grouphug.rb b/data/rbot/plugins/grouphug.rb index 87a7e32c..75093665 100644 --- a/data/rbot/plugins/grouphug.rb +++ b/data/rbot/plugins/grouphug.rb @@ -1,9 +1,11 @@ -# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/) -# (c) 2005 Mark Kretschmann -# Licensed under GPL V2. - -require "net/http" - +#-- vim:sw=2:et +#++ +# +# :title: Grouphug Plugin for rbot +# +# Author:: Mark Kretschmann +# Copyright:: (C) 2005 Mark Kretschmann +# License:: GPL v2 class GrouphugPlugin < Plugin def help( plugin, topic="" ) @@ -14,7 +16,7 @@ class GrouphugPlugin < Plugin path = "random" path = "confessions/#{params[:num]}" if params[:num] begin - data = bot.httputil.get_cached(URI.parse("http://grouphug.us/#{path}")) + data = @bot.httputil.get_cached(URI.parse("http://grouphug.us/#{path}")) reg = Regexp.new( '()(.*?)(

)', Regexp::MULTILINE ) confession = reg.match( data )[4].ircify_html diff --git a/data/rbot/plugins/hl2.rb b/data/rbot/plugins/hl2.rb index e0623433..152afdb9 100644 --- a/data/rbot/plugins/hl2.rb +++ b/data/rbot/plugins/hl2.rb @@ -1,16 +1,21 @@ -# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/) +#-- vim:sw=2:et +#++ +# +# :title: Half-Life 2 plugin for rbot +# +# Author:: Ole Christian Rynning +# Copyright:: (C) 2006 Ole Christian Rynning +# License:: GPL v2 # # Simple Half-Life 2 (Source Engine) plugin to query online # servers to see if its online and kicking and how many users. # # Added 2 seconds timeout to the response. And sockets are now # closing properly. -# -# (c) 2006 Ole Christian Rynning -# Licensed under GPL V2. require 'socket' require 'timeout' + class HL2Plugin < Plugin A2S_INFO = "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00" @@ -50,6 +55,7 @@ class HL2Plugin < Plugin end end + plugin = HL2Plugin.new plugin.map 'hl2 :conn_str' diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb index 48c49dc3..6cbdaf53 100644 --- a/data/rbot/plugins/imdb.rb +++ b/data/rbot/plugins/imdb.rb @@ -1,6 +1,11 @@ -# IMDB plugin for RubyBot -# (c) 2005 Arnaud Cornet -# Licensed under MIT License. +#-- vim:sw=2:et +#++ +# +# :title: IMDB plugin for rbot +# +# Author:: Arnaud Cornet +# Copyright:: (C) 2005 Arnaud Cornet +# License:: MIT license require 'net/http' require 'cgi' diff --git a/data/rbot/plugins/iplookup.rb b/data/rbot/plugins/iplookup.rb index 9da167b0..715595e2 100644 --- a/data/rbot/plugins/iplookup.rb +++ b/data/rbot/plugins/iplookup.rb @@ -1,227 +1,227 @@ -################################################################# -# IP Lookup Plugin -# ---------------------------- -# by Chris Gahan (chris@ill-logic.com) -# -# Purpose: -# ------------------ -# Lets you lookup the owner and their address for any IP address -# or IRC user. -# -################################################################# - -require 'socket' -require 'resolv' - -################################################################# -## ARIN Whois module... -## - -module ArinWhois - - class Chunk < Hash - def customer? - keys.grep(/^(City|Address|StateProv|(Org|Cust)Name)$/).any? - end - - def network? - keys.grep(/^(CIDR|NetHandle|Parent)$/).any? - end - - def contact? - keys.grep(/^(R|Org)(Tech|Abuse)(Handle|Name|Phone|Email)$/).any? - end - - def valid? - customer? or network? or contact? - end - - def owner - self[keys.grep(/^(Org|Cust)Name$/).first] - end - - def location - [ self['City'], self['StateProv'], self['Country'] ].compact.join(', ') - end - - def address - [ self['Address'], location, self['PostalCode'] ].compact.join(', ') - end - - end - - class ArinWhoisParser - - def initialize(data) - @data = data - end - - def split_array_at(a, &block) - return a unless a.any? - a = a.to_a - - results = [] - last_cutpoint = 0 - - a.each_with_index do |el,i| - if block.call(el) - unless i == 0 - results << a[last_cutpoint...i] - last_cutpoint = i - end - end - end - - if last_cutpoint < a.size or last_cutpoint == 0 - results << a[last_cutpoint..-1] - end - - results - end - - # Whois output format - # ------------------------ - # Owner info block: - # {Org,Cust}Name - # Address - # City - # StateProv - # PostalCode - # Country (2-digit) - # - # Network Information: - # CIDR (69.195.25.0/25) - # NetHandle (NET-72-14-192-0-1) - # Parent (NET-72-0-0-0-0) - # - # Contacts: - # ({R,Org}{Tech,Abuse}{Handle,Name,Phone,Email})* - - def parse_chunks - return if @data =~ /^No match found / - chunks = @data.gsub(/^# ARIN WHOIS database, last updated.+/m, '').scan(/(([^\n]+\n)+\n)/m) - chunks.map do |chunk| - result = Chunk.new - - chunk[0].scan(/([A-Za-z]+?):(.*)/).each do |tuple| - tuple[1].strip! - result[tuple[0]] = tuple[1].empty? ? nil : tuple[1] - end - - result - end - end - - - def get_parsed_data - return unless chunks = parse_chunks - - results = split_array_at(parse_chunks) {|chunk|chunk.customer?} - results.map do |chunks| - { - :customer => chunks.select{|x|x.customer?}[0], - :net => chunks.select{|x|x.network?}[0], - :contacts => chunks.select{|x|x.contact?} - } - end - end - - # Return a hash with :customer, :net, and :contacts info filled in. - def get_most_specific_owner - return unless datas = get_parsed_data - - datas_with_bitmasks = datas.map do |data| - bitmask = data[:net]['CIDR'].split('/')[1].to_i - [bitmask, data] - end - #datas_with_bitmasks.sort.each{|x|puts x[0]} - winner = datas_with_bitmasks.sort[-1][1] - end - - end # of class ArinWhoisParser - -module_function - - def raw_whois(query_string, host) - s = TCPsocket.open(host, 43) - s.write(query_string+"\n") - ret = s.read - s.close - return ret - end - - def lookup(ip) - data = raw_whois("+#{ip}", 'whois.arin.net') - arin = ArinWhoisParser.new data - arin.get_most_specific_owner - end - - def lookup_location(ip) - result = lookup(ip) - result[:customer].location - end - - def lookup_address(ip) - result = lookup(ip) - result[:customer].address - end - - def lookup_info(ip) - if result = lookup(ip) - "#{result[:net]['CIDR']} => #{result[:customer].owner} (#{result[:customer].address})" - else - "Address not found." - end - end - -end - - - -################################################################# -## The Plugin -## - -class IPLookupPlugin < Plugin +################################################################# +# IP Lookup Plugin +# ---------------------------- +# by Chris Gahan (chris@ill-logic.com) +# +# Purpose: +# ------------------ +# Lets you lookup the owner and their address for any IP address +# or IRC user. +# +################################################################# + +require 'socket' +require 'resolv' + +################################################################# +## ARIN Whois module... +## + +module ArinWhois + + class Chunk < Hash + def customer? + keys.grep(/^(City|Address|StateProv|(Org|Cust)Name)$/).any? + end + + def network? + keys.grep(/^(CIDR|NetHandle|Parent)$/).any? + end + + def contact? + keys.grep(/^(R|Org)(Tech|Abuse)(Handle|Name|Phone|Email)$/).any? + end + + def valid? + customer? or network? or contact? + end + + def owner + self[keys.grep(/^(Org|Cust)Name$/).first] + end + + def location + [ self['City'], self['StateProv'], self['Country'] ].compact.join(', ') + end + + def address + [ self['Address'], location, self['PostalCode'] ].compact.join(', ') + end + + end + + class ArinWhoisParser + + def initialize(data) + @data = data + end + + def split_array_at(a, &block) + return a unless a.any? + a = a.to_a + + results = [] + last_cutpoint = 0 + + a.each_with_index do |el,i| + if block.call(el) + unless i == 0 + results << a[last_cutpoint...i] + last_cutpoint = i + end + end + end + + if last_cutpoint < a.size or last_cutpoint == 0 + results << a[last_cutpoint..-1] + end + + results + end + + # Whois output format + # ------------------------ + # Owner info block: + # {Org,Cust}Name + # Address + # City + # StateProv + # PostalCode + # Country (2-digit) + # + # Network Information: + # CIDR (69.195.25.0/25) + # NetHandle (NET-72-14-192-0-1) + # Parent (NET-72-0-0-0-0) + # + # Contacts: + # ({R,Org}{Tech,Abuse}{Handle,Name,Phone,Email})* + + def parse_chunks + return if @data =~ /^No match found / + chunks = @data.gsub(/^# ARIN WHOIS database, last updated.+/m, '').scan(/(([^\n]+\n)+\n)/m) + chunks.map do |chunk| + result = Chunk.new + + chunk[0].scan(/([A-Za-z]+?):(.*)/).each do |tuple| + tuple[1].strip! + result[tuple[0]] = tuple[1].empty? ? nil : tuple[1] + end + + result + end + end + + + def get_parsed_data + return unless chunks = parse_chunks + + results = split_array_at(parse_chunks) {|chunk|chunk.customer?} + results.map do |chunks| + { + :customer => chunks.select{|x|x.customer?}[0], + :net => chunks.select{|x|x.network?}[0], + :contacts => chunks.select{|x|x.contact?} + } + end + end + + # Return a hash with :customer, :net, and :contacts info filled in. + def get_most_specific_owner + return unless datas = get_parsed_data + + datas_with_bitmasks = datas.map do |data| + bitmask = data[:net]['CIDR'].split('/')[1].to_i + [bitmask, data] + end + #datas_with_bitmasks.sort.each{|x|puts x[0]} + winner = datas_with_bitmasks.sort[-1][1] + end + + end # of class ArinWhoisParser + +module_function + + def raw_whois(query_string, host) + s = TCPsocket.open(host, 43) + s.write(query_string+"\n") + ret = s.read + s.close + return ret + end + + def lookup(ip) + data = raw_whois("+#{ip}", 'whois.arin.net') + arin = ArinWhoisParser.new data + arin.get_most_specific_owner + end + + def lookup_location(ip) + result = lookup(ip) + result[:customer].location + end + + def lookup_address(ip) + result = lookup(ip) + result[:customer].address + end + + def lookup_info(ip) + if result = lookup(ip) + "#{result[:net]['CIDR']} => #{result[:customer].owner} (#{result[:customer].address})" + else + "Address not found." + end + end + +end + + + +################################################################# +## The Plugin +## + +class IPLookupPlugin < Plugin def help(plugin, topic="") "iplookup [ip address / domain name] => lookup info about the owner of the IP address from the ARIN whois database" - end - - def iplookup(m, params) - reply = "" - if params[:domain] - begin - ip = Resolv.getaddress(params[:domain]) - reply += "#{params[:domain]} | " - rescue => e - m.reply "#{e.message}" - return - end - else - ip = params[:ip] - end - - reply += ArinWhois.lookup_info(ip) - m.reply reply - end - - def userip(m, params) - #users = @channels[m.channel].users - #m.reply "users = #{users.inspect}" - #m.reply @bot.sendq("WHO #{params[:user]}") - end - -end - + end + + def iplookup(m, params) + reply = "" + if params[:domain] + begin + ip = Resolv.getaddress(params[:domain]) + reply += "#{params[:domain]} | " + rescue => e + m.reply "#{e.message}" + return + end + else + ip = params[:ip] + end + + reply += ArinWhois.lookup_info(ip) + m.reply reply + end + + def userip(m, params) + #users = @channels[m.channel].users + #m.reply "users = #{users.inspect}" + #m.reply @bot.sendq("WHO #{params[:user]}") + end + +end + plugin = IPLookupPlugin.new -plugin.map 'iplookup :ip', :action => 'iplookup', :requirements => {:ip => /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/} -plugin.map 'iplookup :domain', :action => 'iplookup', :requirements => {:domain => /^[a-z0-9\.\-]{4,255}$/i} +plugin.map 'iplookup :ip', :action => 'iplookup', :requirements => {:ip => /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/} +plugin.map 'iplookup :domain', :action => 'iplookup', :requirements => {:domain => /^[a-z0-9\.\-]{4,255}$/i} plugin.map 'userip :user', :action => 'userip', :requirements => {:user => /\w+/} - - -if __FILE__ == $0 - include ArinWhois - data = open('whoistest.txt').read - c = ArinWhoisParser.new data - puts c.get_parsed_data.inspect -end \ No newline at end of file + + +if __FILE__ == $0 + include ArinWhois + data = open('whoistest.txt').read + c = ArinWhoisParser.new data + puts c.get_parsed_data.inspect +end diff --git a/data/rbot/plugins/karma.rb b/data/rbot/plugins/karma.rb index f4716e2b..43b3f2dc 100644 --- a/data/rbot/plugins/karma.rb +++ b/data/rbot/plugins/karma.rb @@ -82,6 +82,7 @@ class KarmaPlugin < Plugin end end end + plugin = KarmaPlugin.new plugin.map 'karmastats', :action => 'stats' plugin.map 'karma :key', :defaults => {:key => false} diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb index 9b627fc5..103becb1 100644 --- a/data/rbot/plugins/lart.rb +++ b/data/rbot/plugins/lart.rb @@ -1,24 +1,29 @@ -# Original Author: -# Michael Brailsford -# aka brailsmt -# Author: Giuseppe "Oblomov" Bilotta -# Purpose: Provide for humorous larts and praises -# Original Copyright: -# 2002 Michael Brailsford. All rights reserved. -# Copyright: 2006 Giuseppe Bilotta. All rights reserved. -# License: This plugin is licensed under the BSD license. The terms of -# which follow. +#-- vim:sw=2:et +#++ # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: +# :title: lart/praise plugin for rbot # -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. +# Author:: Michael Brailsford aka brailsmt +# Author:: Giuseppe "Oblomov" Bilotta # -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. +# Copyright:: (C) 2002 Michael Brailsford. All rights reserved. +# Copyright:: (C) 2006 Giuseppe Bilotta. All rights reserved. +# +# License:: This plugin is licensed under the BSD license. The terms of +# which follow. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# Purpose:: Provide for humorous larts and praises class LartPlugin < Plugin diff --git a/data/rbot/plugins/linkbot.rb b/data/rbot/plugins/linkbot.rb index 082cbd80..29d7ad1b 100644 --- a/data/rbot/plugins/linkbot.rb +++ b/data/rbot/plugins/linkbot.rb @@ -1,8 +1,11 @@ #-- vim:sw=2:et #++ # -# Author: Giuseppe "Oblomov" Bilotta -# Copyright (C) 2006 Giuseppe Bilotta +# :title: linkbot management for rbot +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006 Giuseppe Bilotta +# License:: GPL v2 # # Based on an idea by hagabaka (Yaohan Chen ) # @@ -14,8 +17,10 @@ # # This plugin also shows how to create 'fake' messages from a plugin, letting # the bot parse them. +# # TODO a possible enhancement to the Irc framework could be to create 'fake' # servers to make this even easier. + class LinkBot < Plugin BotConfig.register BotConfigArrayValue.new('linkbot.nicks', :default => [], diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index c87dc99d..de33136e 100644 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -192,6 +192,7 @@ class MarkovPlugin < Plugin random_markov(m, message) end end + plugin = MarkovPlugin.new plugin.map 'markov ignore :action :option', :action => "ignore" plugin.map 'markov ignore :action', :action => "ignore" diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb index 7a9ff0c6..85270933 100644 --- a/data/rbot/plugins/nickserv.rb +++ b/data/rbot/plugins/nickserv.rb @@ -1,6 +1,20 @@ +#-- vim:sw=2:et +#++ +# +# :title: Nickserv management plugin for rbot +# +# Author:: Tom Gilbert (giblet) +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2002-2005 Tom Gilbert +# Copyright:: (C) 2006 Tom Gilbert, Giuseppe Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# # Automatically lookup nicks in @registry and identify when asked +# # Takes over proper nick if required and nick is registered -# TODO allow custom IDENTIFY and GHOST names + +# TODO:: allow custom IDENTIFY and GHOST names class NickServPlugin < Plugin diff --git a/data/rbot/plugins/plugin.header b/data/rbot/plugins/plugin.header new file mode 100644 index 00000000..539fa922 --- /dev/null +++ b/data/rbot/plugins/plugin.header @@ -0,0 +1,11 @@ +#-- vim:sw=2:et +#++ +# +# :title: Plugin title +# +# Author:: Your Name Goes Here +# Copyright:: (C) YYYY Your Name +# License:: plugin licence +# +# More documentation, if needed/wanted + diff --git a/data/rbot/plugins/quiz.rb b/data/rbot/plugins/quiz.rb index 30691d4e..7e2c0f83 100644 --- a/data/rbot/plugins/quiz.rb +++ b/data/rbot/plugins/quiz.rb @@ -1,30 +1,30 @@ #-- vim:sw=2:et #++ # -# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/) -# -# A trivia quiz game. Fast paced, featureful and fun. +# :title: Quiz plugin for rbot # # Author:: Mark Kretschmann # Author:: Jocke Andersson # Author:: Giuseppe Bilotta # Author:: Yaohan Chen # -# (c) 2006 Mark Kretschmann, Jocke Andersson, Giuseppe Bilotta -# (c) 2007 Giuseppe Bilotta, Yaohan Chen +# Copyright:: (C) 2006 Mark Kretschmann, Jocke Andersson, Giuseppe Bilotta +# Copyright:: (C) 2007 Giuseppe Bilotta, Yaohan Chen # -# Licensed under GPL V2. +# License:: GPL v2 +# +# A trivia quiz game. Fast paced, featureful and fun. -# FIXME interesting fact: in the Quiz class, @registry.has_key? seems to be -# case insensitive. Although this is all right for us, this leads to rank vs -# registry mismatches. So we have to make the @rank_table comparisons case -# insensitive as well. For the moment, redefine everything to downcase before -# matching the nick. +# FIXME:: interesting fact: in the Quiz class, @registry.has_key? seems to be +# case insensitive. Although this is all right for us, this leads to +# rank vs registry mismatches. So we have to make the @rank_table +# comparisons case insensitive as well. For the moment, redefine +# everything to downcase before matching the nick. # -# TODO define a class for the rank table. We might also need it for scoring in -# other games. +# TODO:: define a class for the rank table. We might also need it for scoring +# in other games. # -# TODO when Ruby 2.0 gets out, fix the FIXME 2.0 UTF-8 workarounds +# TODO:: when Ruby 2.0 gets out, fix the FIXME 2.0 UTF-8 workarounds # Class for storing question/answer pairs QuizBundle = Struct.new( "QuizBundle", :question, :answer ) diff --git a/data/rbot/plugins/roshambo.rb b/data/rbot/plugins/roshambo.rb index 74b94a4c..03338698 100644 --- a/data/rbot/plugins/roshambo.rb +++ b/data/rbot/plugins/roshambo.rb @@ -1,7 +1,13 @@ #-- vim:sw=2:et #++ +# +# :title: Roshambo (rock-paper-scissors) plugin for rbot +# +# Author:: Hans Fugal +# Copyright:: (C) 2004 Hans Fugal +# # Play the game of roshambo (rock-paper-scissors) -# Copyright (C) 2004 Hans Fugal +# # Distributed under the same license as rbot itself require 'time' diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 6b5e62be..caebc3fc 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -1,13 +1,18 @@ #-- vim:sw=2:et #++ # -# RSS feed plugin for RubyBot -# (c) 2004 Stanislav Karchebny -# (c) 2005 Ian Monroe -# (c) 2005 Mark Kretschmann -# (c) 2006 Giuseppe Bilotta +# :title: RSS feed plugin for rbot # -# Licensed under MIT License. +# Author:: Stanislav Karchebny +# Author:: Ian Monroe +# Author:: Mark Kretschmann +# Author:: Giuseppe Bilotta +# +# Copyright:: (C) 2004 Stanislav Karchebny +# Copyright:: (C) 2005 Ian Monroe, Mark Kretschmann +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# +# License:: MIT license require 'rss/parser' require 'rss/1.0' diff --git a/data/rbot/plugins/salut.rb b/data/rbot/plugins/salut.rb index b0bf67e7..feff2dd6 100644 --- a/data/rbot/plugins/salut.rb +++ b/data/rbot/plugins/salut.rb @@ -1,8 +1,17 @@ -# vim: set sw=2 et: +#-- vim:sw=2:et +#++ +# +# :title: Salutations plugin for rbot +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# License:: GPL v2 +# # Salutations plugin: respond to salutations -# TODO allow online editing of salutations -# TODO *REMEMBER* to set @changed to true after edit -# TODO or changes won't be saved +# +# TODO:: allow online editing of salutations +# +# TODO:: *REMEMBER* to set @changed to true after edit or changes won't be saved class SalutPlugin < Plugin BotConfig.register BotConfigBooleanValue.new('salut.all_languages', diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index 3976517f..c091b586 100644 --- a/data/rbot/plugins/script.rb +++ b/data/rbot/plugins/script.rb @@ -1,12 +1,17 @@ -# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/) +#-- vim:sw=2:et +#++ # -# Create mini plugins on IRC. +# :title: Script plugin for rbot +# +# Author:: Mark Kretschmann +# Copyright:: (C) 2006 Mark Kretschmann +# License:: GPL v2 # -# Scripts are little Ruby programs that run in the context of the script plugin. You -# can create them directly in an IRC channel, and invoke them just like normal rbot plugins. +# Create mini plugins on IRC. # -# (c) 2006 Mark Kretschmann -# Licensed under GPL V2. +# Scripts are little Ruby programs that run in the context of the script +# plugin. You can create them directly in an IRC channel, and invoke them just +# like normal rbot plugins. Command = Struct.new( "Command", :code, :nick, :created, :channel ) diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index becfafc2..3b7d6826 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -1,7 +1,18 @@ -# vim: set sw=2 et: +#-- vim:sw=2:et +#++ # -# TODO: use lr=lang_ or whatever is most appropriate to let google know -# it shouldn't use the bot's location to find the preferred language +# :title: Google and Wikipedia search plugin for rbot +# +# Author:: Tom Gilbert (giblet) +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2002-2005 Tom Gilbert +# Copyright:: (C) 2006 Tom Gilbert, Giuseppe Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta + +# TODO:: use lr=lang_ or whatever is most appropriate to let google know +# it shouldn't use the bot's location to find the preferred language + require 'uri' Net::HTTP.version_1_2 diff --git a/data/rbot/plugins/shortenurls.rb b/data/rbot/plugins/shortenurls.rb index 5d8df80a..743cad08 100644 --- a/data/rbot/plugins/shortenurls.rb +++ b/data/rbot/plugins/shortenurls.rb @@ -1,13 +1,15 @@ #-- vim:sw=2:et #++ # +# :title: ShortURL plugin for rbot +# +# Author:: Giuseppe Bilotta +# Copyright:: (C) 2007 Giuseppe Bilotta +# License:: GPL v2 +# # Plugin to handle ShortURL, merges the funcionality of the old rubyurl and tinyurl plugins # Note that it's called ShortenURLs and not ShortURL, to prevent conflicts with # the actual ruby package used -# -# Author:: Giuseppe Bilotta -# (C) 2007 Giuseppe Bilotta -# Based on existing rbot plugins, as mentioned above :) require "shorturl" require "uri" diff --git a/data/rbot/plugins/time.rb b/data/rbot/plugins/time.rb index 9f8b8d7c..96b101ce 100644 --- a/data/rbot/plugins/time.rb +++ b/data/rbot/plugins/time.rb @@ -1,6 +1,11 @@ -# Time Zone Plugin for rbot -# (c) 2006 Ian Monroe -# Licensed under MIT License. +#-- vim:sw=2:et +#++ +# +# :title: Time Zone Plugin for rbot +# +# Author:: Ian Monroe +# Copyright:: (C) 2006 Ian Monroe +# License:: MIT license require 'tzinfo' diff --git a/data/rbot/plugins/topic.rb b/data/rbot/plugins/topic.rb index 93058a01..672bf82a 100644 --- a/data/rbot/plugins/topic.rb +++ b/data/rbot/plugins/topic.rb @@ -1,4 +1,12 @@ -# Author: Giuseppe "Oblomov" Bilotta +#-- vim:sw=2:et +#++ +# +# :title: Topic manipulation plugin for rbot +# +# Author:: Giuseppe Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# License:: GPL v2 +# # Add a bunch of topic manipulation features class TopicPlugin < Plugin diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index 07584d88..88194e90 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -1,10 +1,15 @@ -# Weather plugin for rbot +#-- vim:sw=2:et +#++ # -# NOAA National Weather Service support by MrChucho (mrchucho@mrchucho.net) -# Copyright (C) 2006 Ralph M. Churchill +# :title: Weather plugin for rbot # -# Weather Undeground support by Giuseppe "Oblomov" Bilotta -# Copyright (C) 2006 Giuseppe Bilotta +# Author:: MrChucho (mrchucho@mrchucho.net): NOAA National Weather Service support +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2006 Ralph M. Churchill +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# +# License:: GPL v2 require 'uri' require 'rexml/document' diff --git a/data/rbot/plugins/wow.rb b/data/rbot/plugins/wow.rb index 4faadaf4..1106d3cc 100644 --- a/data/rbot/plugins/wow.rb +++ b/data/rbot/plugins/wow.rb @@ -1,10 +1,13 @@ +#-- vim:sw=2:et +#++ # -# World of Warcraft Realm Status plugin for rbot -# by MrChucho (mrchucho@mrchucho.net) -# Copyright (C) 2006 Ralph M. Churchill +# :title: World of Warcraft Realm Status plugin for rbot # -# Requires: insatiable appetite for World of Warcraft +# Author:: MrChucho (mrchucho@mrchucho.net) +# Copyright:: (C) 2006 Ralph M. Churchill # +# Requires:: insatiable appetite for World of Warcraft + require 'open-uri' require 'rexml/document' diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb index daacdc68..eee50045 100644 --- a/lib/rbot/core/auth.rb +++ b/lib/rbot/core/auth.rb @@ -1,6 +1,11 @@ #-- vim:sw=2:et #++ - +# +# :title: rbot auth management from IRC +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta +# License:: GPL v2 class AuthModule < CoreBotModule diff --git a/lib/rbot/core/basics.rb b/lib/rbot/core/basics.rb index 5c5bcdee..866f506a 100644 --- a/lib/rbot/core/basics.rb +++ b/lib/rbot/core/basics.rb @@ -1,6 +1,11 @@ #-- vim:sw=2:et #++ - +# +# :title: rbot basic management from IRC +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta +# License:: GPL v2 class BasicsModule < CoreBotModule @@ -92,11 +97,6 @@ class BasicsModule < CoreBotModule # when (/^(botsnack|ciggie)$/i) # @bot.say m.replyto, @lang.get("thanks_X") % m.sourcenick if(m.public?) # @bot.say m.replyto, @lang.get("thanks") if(m.private?) - # when (/^(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi(\W|$)|yo(\W|$)).*/i) - # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick if(m.public?) - # @bot.say m.replyto, @lang.get("hello") if(m.private?) - # when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{Regexp.escape(@bot.nick)}$/i) - # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick # when (/^#{Regexp.escape(@bot.nick)}!*$/) # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb index 9ef7ebee..a239e97d 100644 --- a/lib/rbot/core/config.rb +++ b/lib/rbot/core/config.rb @@ -1,6 +1,11 @@ #-- vim:sw=2:et #++ - +# +# :title: rbot config management from IRC +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta +# License:: GPL v2 class ConfigModule < CoreBotModule @@ -163,7 +168,7 @@ class ConfigModule < CoreBotModule # end def bot_version(m, param) - m.reply "I'm a v. #{$version} rubybot, (c) Tom Gilbert - http://linuxbrit.co.uk/rbot/" + m.reply "I'm a v. #{$version} rubybot, (c) Tom Gilbert and the rbot development team - http://linuxbrit.co.uk/rbot/" end def handle_help(m, params) diff --git a/lib/rbot/core/remote.rb b/lib/rbot/core/remote.rb index 43d883dd..35827d89 100644 --- a/lib/rbot/core/remote.rb +++ b/lib/rbot/core/remote.rb @@ -11,7 +11,6 @@ # # TODO find a way to manage session id (logging out, manually and/or # automatically) -# require 'drb/drb' diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index 44487e0d..e882148b 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -1,10 +1,19 @@ #-- vim:sw=2:et #++ # -# Extensions to standard classes, to be used by the various plugins +# :title: Standard classes extensions +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta +# License:: GPL v2 +# +# This file collects extensions to standard Ruby classes and to some core rbot +# classes to be used by the various plugins +# # Please note that global symbols have to be prefixed by :: because this plugin # will be read into an anonymous module + # Extensions to the Array class # class ::Array @@ -18,6 +27,7 @@ class ::Array end end + # Extensions to the String class # # TODO make ircify_html() accept an Hash of options, and make riphtml() just @@ -66,6 +76,7 @@ class ::String end end + # Extensions to the Regexp class, with some common and/or complex regular # expressions. # @@ -139,6 +150,7 @@ class ::Regexp end + module ::Irc diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb index 7566aca4..ff2fb6c6 100644 --- a/lib/rbot/core/utils/httputil.rb +++ b/lib/rbot/core/utils/httputil.rb @@ -1,3 +1,15 @@ +#-- vim:sw=2:et +#++ +# +# :title: rbot HTTP provider +# +# Author:: Tom Gilbert +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2002-2005 Tom Gilbert +# Copyright:: (C) 2006 Tom Gilbert, Giuseppe Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta + module ::Irc module Utils @@ -6,7 +18,7 @@ require 'net/http' begin require 'net/https' rescue LoadError => e - error "Coudln't load 'net/https': #{e.inspect}" + error "Couldn't load 'net/https': #{e.inspect}" error "Secured HTTP connections will fail" end diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb index c2b7d7b1..ac60735d 100644 --- a/lib/rbot/core/utils/utils.rb +++ b/lib/rbot/core/utils/utils.rb @@ -1,3 +1,17 @@ +#-- vim:sw=2:et +#++ +# +# :title: rbot utilities provider +# +# Author:: Tom Gilbert +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2002-2006 Tom Gilbert +# Copyright:: (C) 2007 Giuseppe Bilotta +# +# TODO some of these Utils should be rewritten as extensions to the approriate +# standard Ruby classes and accordingly be moved to extends.rb + require 'net/http' require 'uri' require 'tempfile' diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index a95301dd..bd19e637 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -696,7 +696,7 @@ class IrcBot end quit if $interrupted > 0 @socket.emergency_puts "PASS " + @config['server.password'] if @config['server.password'] - @socket.emergency_puts "NICK #{@config['irc.nick']}\nUSER #{@config['irc.user']} 4 #{@config['server.name']} :Ruby bot. (c) Tom Gilbert" + @socket.emergency_puts "NICK #{@config['irc.nick']}\nUSER #{@config['irc.user']} 4 #{@config['server.name']} :Ruby bot. (c) Tom Gilbert and the rbot development team" quit if $interrupted > 0 myself.nick = @config['irc.nick'] myself.user = @config['irc.user'] diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index cc7fd7e7..4a095dc8 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -836,7 +836,8 @@ module Irc # # ==server events currently supported: # - # TODO handle errors ERR_NOSUCHNICK, ERR_NOSUCHCHANNEL, ERR_CANNOTSENDTOCHAN + # TODO handle errors ERR_NOSUCHNICK, ERR_NOSUCHCHANNEL + # TODO handle errors ERR_CHANOPRIVSNEEDED, ERR_CANNOTSENDTOCHAN # # welcome:: server welcome message on connect # yourhost:: your host details (on connection)