identified.rb 1.17 KB
Newer Older
Cool Fire's avatar
Cool Fire committed
1 2 3 4 5 6 7
#!/usr/bin/env ruby

# Plugin to voice users who are identified with NickServ
class Identified

	# 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
Cool Fire's avatar
Cool Fire committed
13

14
		@channel = "#hackerthreads"
Cool Fire's avatar
Cool Fire committed
15 16 17
	end

	# Method that receives a notification when a user joins (optional)
Cool Fire's avatar
Cool Fire committed
18
	def joined( nick, _user, _host, channel )
Cool Fire's avatar
Cool Fire committed
19 20 21 22 23 24
		if( channel == @channel )
			@irc.message( "NickServ", "status " + nick )
		end
	end

	# Method that receives a notification when a notice is received (optional)
Cool Fire's avatar
Cool Fire committed
25
	def noticed( nick,  _user,  _host,  _to,  message )
Cool Fire's avatar
Cool Fire committed
26 27
		nick.downcase!
		if( nick == "nickserv" )
Cool Fire's avatar
Cool Fire committed
28
			_cmd, subject, status = message.split( ' ', 3 )
Cool Fire's avatar
Cool Fire committed
29 30

			if( status == "3" )
31
				@irc.mode( @channel, "+v" ,subject, true )
Cool Fire's avatar
Cool Fire committed
32 33 34
			end
		end
	end
Cool Fire's avatar
Cool Fire committed
35 36

	# Function to send help about this plugin (Can also be called by the help plugin.)
Cool Fire's avatar
Cool Fire committed
37
	def help( nick, _user, _host, _from, _msg, _arguments, con )
Cool Fire's avatar
Cool Fire committed
38 39 40 41 42 43
		if( con )
			@output.c( "Plugin to voice users that have identified with NickServ.\n" )
		else
			@irc.notice( nick, "Plugin to voice users that have identified with NickServ." )
		end
	end
Cool Fire's avatar
Cool Fire committed
44
end