Class | Irc::Bot::Auth::BotUser
In: | lib/rbot/botuser.rb
Parent: | Object

This is the basic class for bot users: they have a username, a password, a list of netmasks to match against, and a list of permissions. A BotUser can be marked as ‘transient’, usually meaning it‘s not intended for permanent storage. Transient BotUsers have lower priority than nontransient ones for autologin purposes.

To initialize a BotUser, you pass a username and an optional hash of options. Currently, only two options are recognized:

transient: | true or false, determines if the BotUser is transient or permanent (default is false, permanent BotUser). Transient BotUsers are initialized by prepending an asterisk (*) to the username, and appending a sanitized version of the object_id. The username can be empty. A random password is generated. Permanent Botusers need the username as is, and no password is generated.
masks: | an array of Netmasks to initialize the NetmaskList. This list is used as-is for permanent BotUsers. Transient BotUsers will alter the list elements which are Irc::User by globbing the nick and any initial nonletter part of the ident. The masks option is optional for permanent BotUsers, but obligatory (non-empty) for transients.

### Methods

add_netmask autologin= autologin? default? delete_netmask from_hash inspect knows? login login_by_mask? make_permanent new owner? password= permanent= permanent? permit? reset_autologin reset_login_by_mask reset_netmasks reset_password reset_permission reset_temp_permission sanitize_username set_permission set_temp_permission to_hash to_s transient?

### Attributes

login_by_mask | [W] |
netmasks | [R] |
password | [R] |
perm | [R] |
perm_temp | [R] |
transient | [W] |
username | [R] |

### Public Class methods

new(username, options={})

Create a new BotUser with given username

sanitize_username(name)

This method sanitizes a username by chomping, downcasing and replacing any nonalphanumeric character with _

### Public Instance methods

add_netmask(mask)

Adds a Netmask

autologin=(vnew)
autologin?()

Do we allow automatic logging in?

default?()

Check if the current BotUser is the default one

delete_netmask(mask)

Removes a Netmask

from_hash(h)

Restore from hash

inspect()

Inspection

knows?(usr)

This method checks if BotUser has a Netmask that matches user

login(user, password=nil)

This method gets called when User user wants to log in. It returns true or false depending on whether the password is right. If it is, the Netmask of the user is added to the list of acceptable Netmask unless it‘s already matched.

login_by_mask?()

Do we allow logging in without providing the password?

make_permanent(name)

Make the BotUser permanent

owner?()

Check if the current BotUser is the owner

password=(pwd=nil)

This method sets the password if the proposed new password is valid

permanent=(bool)

Sets if the BotUser is permanent or not

permanent?()

Checks if the BotUser is permanent (not transient)

permit?(cmd, chan=nil)

Checks if BotUser is allowed to do something on channel chan, or on all channels if chan is nil

reset_autologin()

Reset the autologin option

reset_login_by_mask()

Reset the login-by-mask option

reset_netmasks()

Reset Netmasks, clearing @netmasks

reset_password()

Resets the password by creating a new onw

reset_permission(cmd, chan ="*")

Resets the permission for command cmd on channel chan

reset_temp_permission(cmd, chan ="*")

Resets the temporary permission for command cmd on channel chan

set_permission(cmd, val, chan="*")

Sets the permission for command cmd to val on channel chan

set_temp_permission(cmd, val, chan="*")

Sets the temporary permission for command cmd to val on channel chan

to_hash()

Convert into a hash

to_s()

In strings

transient?()

Checks if the BotUser is transient

[Validate]