Commit 56580044 authored by Cool Fire's avatar Cool Fire

A little cleanup

parent dba5a075
Pipeline #535 passed with stages
in 7 minutes
......@@ -73,4 +73,4 @@ rubocop:
- ruby
script:
- gem install rubocop --no-ri --no-rdoc
- rubocop -l -f simple --except UnusedMethodArgument,RescueException,Eval,AssignmentInCondition,ScriptPermission
- rubocop -l -f simple --except RescueException,Eval,AssignmentInCondition,ScriptPermission
......@@ -123,7 +123,7 @@ class Commands
end
# Quit command
def quit( nick, user, host, from, msg )
def quit( _nick, _user, host, _from, msg )
if( @config.auth( host, con ) )
if( con )
@output.cbad( "This will also stop the bot, are you sure? [y/N]: " )
......@@ -153,7 +153,7 @@ class Commands
end
# Load modules
def load( nick, user, host, from, msg, auto = false )
def load( nick, _user, host, _from, msg, auto = false )
if( @config.auth( host, con ) )
_cmd, plugin = msg.split( ' ', 2 )
if( plugin != nil )
......@@ -222,7 +222,7 @@ class Commands
end
# Unload module
def unload( nick, user, host, from, msg )
def unload( nick, _user, host, _from, msg )
if( @config.auth( host, con ) )
_cmd, plugin = msg.split( ' ', 2 )
if( plugin != nil )
......@@ -282,14 +282,14 @@ class Commands
end
# Meta funcion to load autoload modules
def autoload( nick = nil, user = nil, host = nil, from = nil, msg = nil )
def autoload( _nick = nil, _user = nil, _host = nil, _from = nil, _msg = nil )
@config.autoload.each do |mod|
load( nil, nil, nil, nil, "dummy " + mod, true )
end
end
# Function to get list of loaded modules
def loaded( nick, user, host, from, msg )
def loaded( nick, _user, _host, _from, _msg )
if( con )
@output.c( "Loaded plugins: " )
@status.plugins.each_key do |plugin_name|
......@@ -308,7 +308,7 @@ class Commands
end
# Function to list available modules
def available( nick, user, host, from, msg )
def available( nick, _user, _host, _from, _msg )
contents = Dir.entries("./" + @config.plugindir + "/" )
plugs = Array.new
contents.entries.each do |file|
......
......@@ -22,7 +22,7 @@ class Btc
@bits_last = 0.0
end
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, from, _msg, _arguments, con )
uri = URI.parse( "https://#{@bits_host}#{@bits_path}" )
http = Net::HTTP.new(uri.host, uri.port)
......@@ -63,7 +63,7 @@ class Btc
end
# Get current value
def mtgox( nick, user, host, from, msg, arguments, con )
def mtgox( _nick, _user, _host, from, _msg, _arguments, con )
uri = URI.parse( "https://#{@api_host}#{@api_path}" )
http = Net::HTTP.new(uri.host, uri.port)
......@@ -139,7 +139,7 @@ class Btc
end
end
# Get last value
def last( nick, user, host, from, msg, arguments, con )
def last( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @bits_host, @bits_path ) )
line = "#{result[ 'last' ]}"
......@@ -152,7 +152,7 @@ class Btc
end
# Get buy price
def buy( nick, user, host, from, msg, arguments, con )
def buy( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @bits_host, @bits_path ) )
line = "Bitstamp will buy your bitcoins for #{result[ 'bid' ]}"
......@@ -165,7 +165,7 @@ class Btc
end
# Get sell price
def sell( nick, user, host, from, msg, arguments, con )
def sell( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @bits_host, @bits_path ) )
line = "Bitstamp will sell you bitcoins for #{result[ 'ask' ]}"
......@@ -178,7 +178,7 @@ class Btc
end
# Get last value
def mtgoxlast( nick, user, host, from, msg, arguments, con )
def mtgoxlast( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @api_host, @api_path ) )
if( result[ "result" ] != "success" )
......@@ -196,7 +196,7 @@ class Btc
end
# Get buy price
def mtgoxbuy( nick, user, host, from, msg, arguments, con )
def mtgoxbuy( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @api_host, @api_path ) )
if( result[ "result" ] != "success" )
......@@ -214,7 +214,7 @@ class Btc
end
# Get sell price
def mtgoxsell( nick, user, host, from, msg, arguments, con )
def mtgoxsell( _nick, _user, _host, from, _msg, _arguments, con )
result = JSON.parse( Net::HTTP.get( @api_host, @api_path ) )
if( result[ "result" ] != "success" )
......@@ -232,7 +232,7 @@ class Btc
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Gets current values from mtgox",
" btc - Get bitstamp exchange rate (buying rate)",
......
......@@ -13,7 +13,7 @@ class Calc
end
# Default method, called when no argument is given (optional, but highly recomended)
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, from, _msg, arguments, _con )
# Check for invalid input
if( arguments =~ /^([0-9]|\.|,|\+|-|\*|\^|\/|%|\(|\)|E|pi|acos|acosh|asin|asinh|atan|atanh|cbrt|cos|cosh|erf|erfc|exp|frexp|gamma|hypot|ldexp|lgamma|log|sin|sinh|sqrt|tan|tanh| )+$/i )
......@@ -77,7 +77,7 @@ class Calc
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This plugin allows you to do some math.",
" calc 5*5 - Do some calculation.",
......
......@@ -11,7 +11,7 @@ class Core
end
# Messaging commands
def message( nick, user, host, from, msg, arguments, con )
def message( nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
to, message = arguments.split( ' ', 2 )
......@@ -29,7 +29,7 @@ class Core
end
end
def raw( nick, user, host, from, msg, arguments, con )
def raw( nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
@irc.raw( arguments )
......@@ -43,7 +43,7 @@ class Core
end
end
def action( nick, user, host, from, msg, arguments, con )
def action( nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
to, action = arguments.split( ' ', 2 )
......@@ -61,7 +61,7 @@ class Core
end
end
def notice( nick, user, host, from, msg, arguments, con )
def notice( nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
to, message = arguments.split( ' ', 2 )
......@@ -80,7 +80,7 @@ class Core
end
# Join/part commands
def join( nick, user, host, from, msg, chan, con )
def join( nick, _user, host, _from, _msg, chan, con )
if( @config.auth( host, con ) )
if( !chan.nil? && !chan.empty? )
@irc.join( chan )
......@@ -94,7 +94,7 @@ class Core
end
end
def part( nick, user, host, from, msg, chan, con )
def part( nick, _user, host, _from, _msg, chan, con )
if( @config.auth( host, con ) )
if( !chan.nil? && !chan.empty? )
@irc.part( chan )
......@@ -109,7 +109,7 @@ class Core
end
# Mode command
def mode( nick, user, host, from, msg, arguments, con )
def mode( nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -134,7 +134,7 @@ class Core
end
# Oper commands
def op( nick, user, host, from, msg, arguments, con )
def op( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -161,7 +161,7 @@ class Core
end
end
def deop( nick, user, host, from, msg, arguments, con )
def deop( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -189,7 +189,7 @@ class Core
end
# Half-oper commands
def hop( nick, user, host, from, msg, arguments, con )
def hop( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -216,7 +216,7 @@ class Core
end
end
def dehop( nick, user, host, from, msg, arguments, con )
def dehop( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -244,7 +244,7 @@ class Core
end
# Voice commands
def voice( nick, user, host, from, msg, arguments, con )
def voice( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -271,7 +271,7 @@ class Core
end
end
def devoice( nick, user, host, from, msg, arguments, con )
def devoice( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( arguments == nil )
arguments = ""
......@@ -299,7 +299,7 @@ class Core
end
# Kick commands
def kick( nick, user, host, from, msg, arguments, con )
def kick( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
if( arguments =~ /^#/ )
......@@ -325,7 +325,7 @@ class Core
end
# Banning commands
def ban( nick, user, host, from, msg, arguments, con )
def ban( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
chan, host = arguments.split( ' ', 2 )
......@@ -346,7 +346,7 @@ class Core
end
end
def unban( nick, user, host, from, msg, arguments, con )
def unban( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
chan, host = arguments.split( ' ', 2 )
......@@ -367,7 +367,7 @@ class Core
end
end
def timeban( nick, user, host, from, msg, arguments, con )
def timeban( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( @config.threads && @status.threads )
if( !arguments.nil? && !arguments.empty? )
......@@ -415,7 +415,7 @@ class Core
end
# Echo uptime to the user
def uptime( nick, user, host, from, msg, arguments, con )
def uptime( nick, _user, _host, _from, _msg, _arguments, con )
uptime = "Uptime: " + @status.uptime + "."
if( con )
@output.cinfo( uptime )
......@@ -424,7 +424,7 @@ class Core
end
end
def nick( nick, user, host, from, msg, arguments, con )
def nick( _nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
@config.nick( arguments )
......
......@@ -15,7 +15,7 @@ class Ddg
end
# Method that receives a notification when a user joins (optional)
def joined( nick, user, host, channel )
def joined( nick, _user, _host, channel )
if( channel == @channel )
@irc.mode( channel, "+v" ,nick, true )
end
......
......@@ -18,7 +18,7 @@ class Debug
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Plugin to help with debugging.",
" debug threadlist - Print list of threads to console.",
......@@ -38,7 +38,7 @@ class Debug
end
# Show backtrace of specific thread
def threadtrace( nick, user, host, from, msg, arguments, con )
def threadtrace( _nick, _user, _host, _from, _msg, arguments, _con )
Thread.list.each do |thr|
if( thr.to_s =~ /#{arguments}/ )
thr.backtrace.each do |level|
......@@ -51,7 +51,7 @@ class Debug
# List all threads + status
def threadlist( nick, user, host, from, msg, arguments, con )
def threadlist( _nick, _user, _host, _from, _msg, _arguments, _con )
Thread.list.each do |thr|
@output.info( "#{thr.inspect}\n" )
end
......@@ -59,7 +59,7 @@ class Debug
end
# Kill thread
def threadkill( nick, user, host, from, msg, arguments, con )
def threadkill( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
Thread.list.each do |thr|
if( thr.to_s =~ /#{arguments}/ )
......@@ -72,7 +72,7 @@ class Debug
end
# Set debug level
def level( nick, user, host, from, msg, arguments, con )
def level( nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
@status.debug( arguments.to_i )
@irc.notice( nick, "Set debug level to #{arguments}" )
......
......@@ -14,12 +14,12 @@ class Delay
end
# Default method
def main( nick, user, host, from, msg, arguments, con )
def main( nick, _user, _host, _from, _msg, _arguments, _con )
@irc.notice( nick, "Use 'ruby' or 'irc' as the method.")
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This plugin to delay actions.",
" delay ruby [seconds] [action] - Set ruby command to be carried out later."
......@@ -36,7 +36,7 @@ class Delay
end
# Functions to do delayed actions
def ruby( nick, user, host, from, msg, arguments, con )
def ruby( _nick, _user, host, from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
delay, action = arguments.split( ' ', 2 )
......
......@@ -20,39 +20,39 @@ class Demo
end
# Default method, called when no argument is given (optional, but highly recomended)
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, from, _msg, _arguments, _con )
@irc.message( from, "This is the demo module, function, function_admin and remote are availble." )
end
# Method that receives a notification when a user is kicked (optional)
def kicked( nick, user, host, channel, kicked, reason )
def kicked( nick, _user, _host, channel, kicked, reason )
@irc.message( channel, kicked + " was kicked by " + nick + " for " + reason + "." )
end
# Method that receives a notification when a notice is received (optional)
def noticed( nick, user, host, to, message )
def noticed( nick, _user, _host, _to, message )
@irc.message( nick, "Received notice from: " + nick + ": " + message )
end
# Method that receives a notification when a message is received, that is not a command (optional)
def messaged( nick, user, host, from, message )
def messaged( nick, _user, _host, from, message )
if( @config.nick != nick )
@irc.message( from, "Received message from: " + nick + ": " + message )
end
end
# Method that receives a notification when a user joins (optional)
def joined( nick, user, host, channel )
def joined( nick, _user, _host, channel )
@irc.message( channel, nick + " joined " + channel + "." )
end
# Method that receives a notification when a user parts (optional)
def parted( nick, user, host, channel )
def parted( nick, _user, _host, channel )
@irc.message( channel, nick + " parted " + channel + "." )
end
# Method that receives a notification when a user quits (optional)
def quited( nick, user, host, message )
def quited( nick, _user, _host, message )
@output.std( nick + " quit: " + message )
end
......@@ -72,7 +72,7 @@ class Demo
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This plugin demonstrates the working of plugins.",
" demo function - Public plugin function.",
......@@ -90,12 +90,12 @@ class Demo
end
# Generic function that can be called by any user
def function( nick, user, host, from, msg, arguments, con )
def function( nick, _user, _host, from, _msg, _arguments, _con )
@irc.message( from, nick + " called \"function\" from " + from + "." )
end
# Generic function that can only be called by an admin
def functionadmin( nick, user, host, from, msg, arguments, con )
def functionadmin( nick, _user, host, from, _msg, _arguments, con )
if( @config.auth( host, con ) )
# Admin only code goes in here
@irc.message( from, nick + " called \"function_admin\" from " + from + "." )
......
......@@ -21,7 +21,7 @@ class Dogecoin
end
# Alias for last
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, from, _msg, _arguments, con )
uri = URI.parse( "http://#{@api_host}#{@api_path}" )
http = Net::HTTP.new( uri.host, uri.port )
......@@ -54,7 +54,7 @@ class Dogecoin
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Gets current litecoin values from Btc-e",
" dogecoin - Get DOGE/BTC exchange rate"
......
......@@ -18,7 +18,7 @@ class Git
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This plugin allows you to pull updates from a git repo.",
"Will only work if you cloned the bot from git.",
......@@ -37,7 +37,7 @@ class Git
end
# Pull updates from server
def pull( nick, user, host, from, msg, arguments, con )
def pull( nick, _user, host, _from, _msg, _arguments, con )
if( @config.auth( host, con ) )
res = %x( git pull ).gsub!( "\n", " " )
@irc.notice( nick, "#{res}" )
......@@ -45,7 +45,7 @@ class Git
end
# Show some output and status
def status( nick, user, host, from, msg, arguments, con )
def status( nick, _user, _host, _from, _msg, _arguments, _con )
branch = %x( git branch | head -n 1 | awk '{print $2}' )
status = %x( git fetch -v --dry-run 2>&1 >/dev/null | grep #{branch} )
......
......@@ -47,7 +47,7 @@ class Hackerthreads
end
# Default method
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, _from, _msg, _arguments, _con )
check_rss
end
private
......
......@@ -15,14 +15,14 @@ class Identified
end
# Method that receives a notification when a user joins (optional)
def joined( nick, user, host, channel )
def joined( nick, _user, _host, channel )
if( channel == @channel )
@irc.message( "NickServ", "status " + nick )
end
end
# Method that receives a notification when a notice is received (optional)
def noticed( nick, user, host, to, message )
def noticed( nick, _user, _host, _to, message )
nick.downcase!
if( nick == "nickserv" )
_cmd, subject, status = message.split( ' ', 3 )
......@@ -34,7 +34,7 @@ class Identified
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
if( con )
@output.c( "Plugin to voice users that have identified with NickServ.\n" )
else
......
......@@ -37,7 +37,7 @@ class Kamikaze
end
# Help method
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This module provides the ability to kick other users, but at a terrible price!",
" kamikaze [user] - Kick a user.",
......
......@@ -50,7 +50,7 @@ class Login
end
# Function to set password
def set( nick, user, host, from, msg, arguments, con )
def set( _nick, _user, host, _from, _msg, arguments, con )
if( @config.auth( host, con ) )
if( !arguments.nil? && !arguments.empty? )
@password = BCrypt::Password.create arguments
......@@ -60,7 +60,7 @@ class Login
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"This plugin allows users to log in with a password when their hostmask is not in the oper list.",
" login [password] - Login with password.",
......
......@@ -20,7 +20,7 @@ class Ltc
end
# Alias for last
def main( nick, user, host, from, msg, arguments, con )
def main( _nick, _user, _host, from, _msg, _arguments, con )
uri = URI.parse( "https://#{@api_host}#{@api_path}" )
http = Net::HTTP.new(uri.host, uri.port)
......@@ -68,7 +68,7 @@ class Ltc
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Gets current litecoin values from Btc-e",
" btc - Get Btc-e exchange rate (buying rate)"
......
......@@ -76,7 +76,7 @@ class Memo
end
# Send memo to user
def send( nick, user, host, from, msg, arguments, con )
def send( nick, _user, _host, _from, msg, arguments, con )
if( !arguments.nil? && !arguments.empty? )
arguments = arguments.split()
......@@ -111,7 +111,7 @@ class Memo
end
# Read memos
def read( nick, user, host, from, msg, arguments, con, print = true )
def read( nick, _user, _host, _from, _msg, arguments, con, print = true )
nick = nick.downcase.to_s.encode('utf-8')
count = @recordcount.execute( :receiver => nick ).next[0]
......@@ -192,7 +192,7 @@ class Memo
end
# Output some plugin state
def status( nick, user, host, from, msg, arguments, con )
def status( nick, _user, _host, _from, _msg, _arguments, con )
warmup = ( @cache.size.to_f / @maxcache.to_f ) * 100
warmup = ( warmup * 10 ).round / 10.0
......@@ -206,7 +206,7 @@ class Memo
end
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, user, host, from, msg, arguments, con )
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Send and read memos",
" memo send [user] [message] - Send memo to a user.",
......@@ -237,7 +237,7 @@ class Memo
end
# Check if user is alive
def messaged( nick, user, host, from, message )
def messaged( nick, _user, _host, from, _message )
@output.debug("messaged\n")
nick = nick.downcase.to_s.encode('utf-8')
......
......@@ -63,7 +63,7 @@ class Mibs
end
# Check if mib has been here before on join
def joined( nick, user, host, channel )
def joined( nick, user, _host, _channel )
# See if user looks like mib
if( user =~ /^[0-9a-f]{8}/ )
nick = nick.to_s.encode('utf-8')
......@@ -99,7 +99,7 @@ class Mibs