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

Inherits:
BotUser show all
Includes:
Singleton
Defined in:
/home/apoc/projects/ruby/rbot/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 included from Singleton

#_dump

Methods inherited from BotUser

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

Constructor Details

- (DefaultBotUserClass) initialize

The default BotUser is named 'everyone'



538
539
540
541
542
543
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 538

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

Instance Method Details

- (Object) autologin=(val)

This method returns without changing anything



560
561
562
563
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 560

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

- (Boolean) knows?(user)

default knows everybody

Returns:

  • (Boolean)


581
582
583
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 581

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

- (Object) login(user, password)

We always allow logging in as the default user



586
587
588
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 586

def (user, password)
  return true
end

- (Object) login_by_mask=(val)

This method returns without changing anything



547
548
549
550
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 547

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

- (Boolean) permit?(cmd, chan = nil)

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

Returns:

  • (Boolean)


594
595
596
597
598
599
600
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 594

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

- (Object) reset_autologin

The default botuser doesn't allow autologin (meaningless)



567
568
569
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 567

def reset_autologin
  @autologin = false
end

- (Object) reset_login_by_mask

The default botuser allows logins by mask



554
555
556
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 554

def 
  @login_by_mask = true
end

- (Object) set_default_permission(cmd, val)

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



574
575
576
577
# File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 574

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