kamikaze.rb 1.37 KB
Newer Older
1 2
#!/usr/bin/env ruby

3
# Plugin that allows people to kick random users, at the price of also being kicked, and banned for n seconds
4 5 6 7
class Kamikaze

	# This method is called when the plugin is first loaded
	def initialize( status, config, output, irc, timer )
8 9 10 11 12
		@status  = status
		@config  = config
		@output  = output
		@irc     = irc
		@timer   = timer
13

14
		@bantime = 120
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
	end

	# Default method
	def main( nick, user, host, from, msg, arguments, con )
		if( !arguments.nil? && !arguments.empty? )
			arguments.gsub!( / /, "" )
			if( arguments != @config.nick )
				# Kick target
				@irc.kick( from, arguments, nick + " really hates you." )
				
				# Ban issuer
				@irc.mode( from, "+b", host )

				# Kick issuer
				@irc.kick( from, nick, "See you in " + @bantime.to_s + " seconds." )

				# Set unban for issuer
				@timer.action( @bantime, "@irc.mode( \"#{from}\", \"-b\", \"#{host}\" )" )
			end
		else
			help( nick, user, host, from, msg, arguments, con )
		end
	end

	# Help method
Cool Fire's avatar
Cool Fire committed
40
	def help( nick, _user, _host, _from, _msg, _arguments, con )
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
		help = [
			"This module provides the ability to kick other users, but at a terrible price!",
			"  kamikaze [user]            - Kick a user.",
			"  kamikaze help              - Provides this help."
		]

		# Print out help
		help.each do |line|
			if( con )
				@output.c( line + "\n" )
			else
				@irc.notice( nick, line )
			end
		end
	end
end