Class: Irc::Bot::Auth::DefaultBotUserClass

Inherits:
BotUser show all
Includes:
Singleton
Defined in:
lib/rbot/botuser.rb

Overview

This is the default BotUser: it’s used for all users which haven’t identified with the bot

Instance Attribute Summary

Attributes inherited from BotUser

#login_by_mask, #netmasks, #password, #perm, #perm_temp, #transient, #username

Instance Method Summary collapse

Methods inherited from BotUser

#add_netmask, #autologin?, #default?, #delete_netmask, #from_hash, #inspect, #login_by_mask?, #make_permanent, #owner?, #permanent=, #permanent?, #remote_login, #reset_netmasks, #reset_password, #reset_permission, #reset_temp_permission, sanitize_username, #set_permission, #set_temp_permission, #to_hash, #to_s, #transient?

Constructor Details

#initializeDefaultBotUserClass

The default BotUser is named ‘everyone’



537
538
539
540
541
542
# File 'lib/rbot/botuser.rb', line 537

def initialize
  
  reset_autologin
  super("everyone")
  @default_perm = PermissionSet.new
end

Instance Method Details

#autologin=(val) ⇒ Object

This method returns without changing anything



559
560
561
562
# File 'lib/rbot/botuser.rb', line 559

def autologin=(val)
  debug "Tried to change the autologin for default bot user, ignoring"
  return
end

#knows?(user) ⇒ Boolean

default knows everybody

Returns:

  • (Boolean)


580
581
582
# File 'lib/rbot/botuser.rb', line 580

def knows?(user)
  return true if user.to_irc_user
end

#login(user, password) ⇒ Object

We always allow logging in as the default user



585
586
587
# File 'lib/rbot/botuser.rb', line 585

def (user, password)
  return true
end

#login_by_mask=(val) ⇒ Object

This method returns without changing anything



546
547
548
549
# File 'lib/rbot/botuser.rb', line 546

def (val)
  debug "Tried to change the login-by-mask for default bot user, ignoring"
  return @login_by_mask
end

#permit?(cmd, chan = nil) ⇒ Boolean

DefaultBotUser will check the default_perm after checking the global ones or on all channels if chan is nil

Returns:

  • (Boolean)


593
594
595
596
597
598
599
# File 'lib/rbot/botuser.rb', line 593

def permit?(cmd, chan=nil)
  allow = super(cmd, chan)
  if allow.nil? && chan.nil?
    allow = @default_perm.permit?(cmd)
  end
  return allow
end

#reset_autologinObject

The default botuser doesn’t allow autologin (meaningless)



566
567
568
# File 'lib/rbot/botuser.rb', line 566

def reset_autologin
  @autologin = false
end

#reset_login_by_maskObject

The default botuser allows logins by mask



553
554
555
# File 'lib/rbot/botuser.rb', line 553

def 
  @login_by_mask = true
end

#set_default_permission(cmd, val) ⇒ Object

Sets the default permission for the default user (i.e. the ones set by the BotModule writers) on all channels



573
574
575
576
# File 'lib/rbot/botuser.rb', line 573

def set_default_permission(cmd, val)
  @default_perm.set_permission(Command.new(cmd), val)
  debug "Default permissions now: #{@default_perm.pretty_inspect}"
end