# Author: # Copyright: All Content Unless Otherwise Stated Copyright © 2008 Foxonastick.com # License: BSD license require 'rbot/plugins' class OperServ < Plugin def help(plugin, topic="") case plugin when "oper" return "oper : Allows bot to execute commands in oper mode, once command is executed the bot will downgrade to regular user" when "wallops" return "wallops : Allows bot to send a message to all users with umode +w" when "globops" return "globops : Allows bot to send a message to all IRCops" when "chatops" return "chatops : Allows bot to send a message to all IRCops with umode +c" when "locops" return "locops : Allows bot to send a message to all local IRCops" end return "operserv : Allows the bot to /oper and use some of the basic commands. Commands are: oper, wallops, globops, chatops, locops" end def oper_command(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick @bot.sendq "OPER #{username} #{password}" @bot.sendq (params[:command].to_s) @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def wallops_message(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "WALLOPS #{message}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def globops_message(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GLOBOPS #{message}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def chatops_message(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHATOPS #{message}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def locops_message(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "LOCOPS #{message}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def shun_user(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick nick = params[:nick] time = params[:time] reason = params[:reason] @bot.sendq "OPER #{username} #{password}" @bot.sendq "SHUN #{nick} #{time} :#{reason}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def unshun_user(m, params=nil) operchan = "#channel which opers automatically joins if successful oper" username = "bot's oper username here" password = "bot's oper password here" bothost = "bot's regular hostname here" botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "SHUN -#{nick}" @bot.sendq "CHGHOST #{botnick} #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end end plugin = OperServ.new plugin.default_auth( 'act', false ) plugin.map 'oper *command', :action => 'oper_command', :auth_path => 'act' plugin.map 'wallops :message', :action => 'wallops_message', :auth_path => 'act' plugin.map 'globops :message', :action => 'globops_message', :auth_path => 'act' plugin.map 'chatops :message', :action => 'chatops_message', :auth_path => 'act' plugin.map 'locops :message', :action => 'chatops_message', :auth_path => 'act' plugin.map 'shun :nick :time :reason', :action => 'shun_user', :defaults => {:time => 0, :reason => "Requested"}, :auth_path => 'act' plugin.map 'unshun :nick', :action => 'unshun_user', :auth_path => 'act'