# Author: # Copyright: All Content Unless Otherwise Stated Copyright © 2008 Foxonastick.com # License: BSD license require 'rbot/plugins' class OperServ < Plugin TimeReq = /^\d+[smhd]$/ # Modify The Following Values Which Are In CAPITALS. Or The Bot Won't Be Able To Oper Or Execute Oper Commands. Config.register Config::StringValue.new('oper.chan', :default => "#OPER CHANNEL USERS JOIN AUTOMATICALLY JOIN ONCE THEY BECOME OPER") Config.register Config::StringValue.new('user.name', :default => "BOT'S OPER USERNAME HERE") Config.register Config::StringValue.new('pass.word', :default => "BOT'S OPER PASSWORD HERE") Config.register Config::StringValue.new('bot.host', :default => "BOT'S HOSTNAME WHEN BOT IS REGULAR USER (WITHOUT @ IN FRONT), e.g bot@lol.com, the hostname for this is lol.com") Config.register Config::StringValue.new('restart.pass', :default => "PASSWORD FOR /RESTART, IF YOU DON'T HAVE ONE LEAVE THIS EMPTY, JUST DELETE THIS SENTENCE, EXCLUDING THE QUOTES") Config.register Config::StringValue.new('die.pass', :default => "PASSWORD FOR /DIE, IF YOU DON'T HAVE ONE LEAVE THIS EMPTY, JUST DELETE THIS SENTENCE, EXCLUDING THE QUOTES") # DON'T MODIFY ANYTHING AFTER THIS LINE def help(plugin, topic="") case plugin when "oper" return "oper : executes the specified command in oper mode, once command is executed the bot will downgrade to regular user" when "wallops" return "wallops : send the specified message to all users with user mode +w" when "globops" return "globops : send the specified message to all IRCops" when "chatops" return "chatops : send the specified message to all IRCops with user mode +c" when "locops" return "locops : send the specified message to all local IRCops" when "adchat" return "adchat : send the specified message to all Admins" when "nachat" return "nachat : send the specified message to Net Admins" when "kill" return "kill [reason...] : disconnect a user from the network" when "kline" return "kline [Xs/m/h/d] [reason...] : bans a hostmask from the server issued on for the specified amount of time with the specified reason, however user can still access other servers on the network. not a global ban" when "unkline" return "unkline : removes an existing kline" when "zline" return "zline [Xs/m/h/d] [reason...] : bans an IP address from the server issued on for the specified amount of time with the specified reason, however user can still access other servers on the network. not a global ban" when "unzline" return "unzline : removes an existing zline" when "gline" return "gline [Xs/m/h/d] [reason...] : bans a hostmask from the network for the specified amount of time with the specified reason, user can't access the network rendering all other servers inaccessible. is a global kline" when "ungline" return "ungline : removes an existing gline" when "shun" return "shun [Xs/m/h/d] [reason...] : prevents a user from executing any commands except for ADMIN and responding to server pings for the specified amount of time with the specified reason, this is effective on the whole network including all the servers on it. has a global effect" when "unshun" return "unshun : removes an existing shun" when "gzline" return "gzline [Xs/m/h/d] [reason...] : bans an IP address from the network for the specified amount of time with the specified reason, user can't access the network rendering all other servers inaccessible. is a global zline" when "ungzline" return "ungzline : removes an existing gzline" when "rehash" return "rehash : rehashes the server's config file. including a server name allows you to rehash a remote server's config file. Including a flag let;s you rehash certain files or do different things. the flags are: motd - Only rehash all MOTD and RULES files (including tld {}), opermotd - Only rehash the OPERMOTD file, botmotd - Only rehash the BOTMOTD file, garbage - Force garbage collection" when "restart" return "restartserver [reason...] : restarts the IRCD process with the specified reason" when "die" return "dieserver : terminates the IRCD process" when "sethost" return "sethost : changes the hostname of the user who issued the command" when "setident" return "setident : changes the ident of the user who issued the command" when "chghost" return "chghost : changes the hostname of a user currently on the network" when "chgident" return "chgident : changes the ident of a user currently on the network" when "chgname" return "chgname : changes the irc name/real name of a user currently on the network" end return "operserv : Allows the bot to /oper and use most of the oper commands. Bot will automatically downgrade to regular user once command is executed. Commands are: oper, wallops, globops, chatops, locops, adchat, nachat, [un]kill, [un]kline, [un]zline, [un]gline, [un]shun, [un]gzline, rehash, restartserver, dieserver, sethost, setident, chghost, chgident and chgname" end def oper_command(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick @bot.sendq "OPER #{username} #{password}" @bot.sendq (params[:command].to_s) @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def wallops_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "WALLOPS #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def globops_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GLOBOPS #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def chatops_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHATOPS #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def locops_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "LOCOPS #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def adchat_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "ADCHAT #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def nachat_message(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "NACHAT #{message}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def kill_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] reason = params[:reason] message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "KILL #{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def kline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] time = params[:time] reason = params[:reason] message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "KLINE #{nick} #{time} :#{reason}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def unkline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "KLINE -#{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def zline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] time = params[:time] reason = params[:reason] message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "ZLINE #{nick} #{time} :#{reason}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def unzline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "ZLINE -#{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def gline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] time = params[:time] reason = params[:reason] message = params[:message] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GLINE #{nick} #{time} :#{reason}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def ungline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GLINE -#{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def shun_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] 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 "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def unshun_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "SHUN -#{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def gzline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] time = params[:time] reason = params[:reason] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GZLINE #{nick} #{time} :#{reason}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def ungzline_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] @bot.sendq "OPER #{username} #{password}" @bot.sendq "GZLINE -#{nick}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def rehash_server(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick servername = params[:servername] flags = params[:flags] @bot.sendq "OPER #{username} #{password}" @bot.sendq "REHASH #{servername} -#{flags}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def restart_server(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick restartpass = @bot.config['restart.pass'] reason = params[:reason] @bot.sendq "OPER #{username} #{password}" @bot.sendq "RESTART #{restartpass} :#{reason}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def die_server(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick diepass = @bot.config['die.pass'] @bot.sendq "OPER #{username} #{password}" @bot.sendq "DIE #{diepass}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def sethost_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = m.sourcenick host = params[:host] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHGHOST #{nick} #{host}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def setident_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = m.sourcenick ident = params[:ident] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHGIDENT #{nick} #{ident}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def chghost_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] host = params[:host] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHGHOST #{nick} #{host}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def chgident_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] ident = params[:ident] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHGIDENT #{nick} #{ident}" @bot.sendq "SETHOST #{bothost}" @bot.sendq "MODE #{botnick} -ostk" @bot.sendq "PART #{operchan}" end def chgname_user(m, params=nil) operchan = @bot.config['oper.chan'] username = @bot.config['user.name'] password = @bot.config['pass.word'] bothost = @bot.config['bot.host'] botnick = @bot.nick nick = params[:nick] name = params[:ident] @bot.sendq "OPER #{username} #{password}" @bot.sendq "CHGNAME #{nick} #{name}" @bot.sendq "SETHOST #{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 => 'locops_message', :auth_path => 'act' plugin.map 'adchat :message', :action => 'adchat_message', :auth_path => 'act' plugin.map 'nachat :message', :action => 'nachat_message', :auth_path => 'act' plugin.map 'kill :nick :reason', :action => 'kill_user', :defaults => {:reason => "Requested"}, :auth_path => 'act' plugin.map 'kline :nick :time :reason', :action => 'kline_user', :requirements => {:time => OperServ::TimeReq}, :defaults => {:time => "0", :reason => "Requested"}, :auth_path => 'act' plugin.map 'unkline :nick', :action => 'unkline_user', :auth_path => 'act' plugin.map 'zline :nick :time :reason', :action => 'zline_user', :requirements => {:time => OperServ::TimeReq}, :defaults => {:time => "0", :reason => "Requested"}, :auth_path => 'act' plugin.map 'unzline :nick', :action => 'unzline_user', :auth_path => 'act' plugin.map 'gline :nick :time :reason', :action => 'gline_user', :requirements => {:time => OperServ::TimeReq}, :defaults => {:time => "0", :reason => "Requested"}, :auth_path => 'act' plugin.map 'ungline :nick', :action => 'ungline_user', :auth_path => 'act' plugin.map 'shun :nick :time :reason', :action => 'shun_user', :requirements => {:time => OperServ::TimeReq}, :defaults => {:time => "0", :reason => "Requested"}, :auth_path => 'act' plugin.map 'unshun :nick', :action => 'unshun_user', :auth_path => 'act' plugin.map 'gzline :nick :time :reason', :action => 'gzline_user', :requirements => {:time => OperServ::TimeReq}, :defaults => {:time => "0", :reason => "Requested"}, :auth_path => 'act' plugin.map 'ungzline :nick', :action => 'ungzline_user', :auth_path => 'act' plugin.map 'rehash :servername :flags', :action => 'rehash_server', :defaults => {:servername => "", :flags => ""}, :auth_path => 'act' plugin.map 'restartserver :reason', :action => 'restart_server', :defaults => {:reason => "Requested"}, :auth_path => 'act' plugin.map 'dieserver', :action => 'die_server', :auth_path => 'act' plugin.map 'sethost :host', :action => 'sethost_user', :auth_path => 'act' plugin.map 'setident :ident', :action => 'setident_user', :auth_path => 'act' plugin.map 'chghost :nick :host', :action => 'chghost_user', :auth_path => 'act' plugin.map 'chgident :nick :ident', :action => 'chgident_user', :auth_path => 'act' plugin.map 'chgname :nick :name', :action => 'chgname_user', :auth_path => 'act'