Class: Irc::User

Class | Irc::User
In: | lib/rbot/botuser.rb lib/rbot/irc.rb
Parent: | Object

An IRC User is identified by his/her Netmask (which must not have globs). In fact, User is just a subclass of Netmask.

Ideally, the user and host information of an IRC User should never change, and it shouldn‘t contain glob patterns. However, IRC is somewhat idiosincratic and it may be possible to know the nick of a User much before its user and host are known. Moreover, some networks (namely Freenode) may change the hostname of a User when (s)he identifies with Nickserv.

As a consequence, we must allow changes to a User host and user attributes. We impose a restriction, though: they may not contain glob patterns, except for the special case of an unknown user/host which is represented by a *.

It is possible to create a totally unknown User (e.g. for initializations) by setting the nick to * too.

TODO list:

- see if it‘s worth to add the other USER data
- see if it‘s worth to add NICKSERV status

### Methods

away= away? botuser channels host= is_op? is_voice? known? modes_on new nick= replace to_irc_user user=

### External Aliases

nick | -> | to_s

### Attributes

idle_since | [RW] |
real_name | [RW] |
signon | [RW] |

### Public Class methods

new(str="", opts={})

Create a new IRC User from a given Netmask (or anything that can be converted into a Netmask) provided that the given Netmask does not have globs.

### Public Instance methods

away=(msg="")

Set the away status of the user. Use away=(nil) or away=(false) to unset away

away?()

Is the user away?

botuser()

A convenience method to automatically found the botuser associated with the receiver

channels()
host=(newhost)

We have to allow changing the host of an Irc User due to some networks (e.g. Freenode) changing hostmasks on the fly. We still check if the new host data has glob patterns though.

is_op?(channel)
is_voice?(channel)
known?()

Checks if a User is well-known or not by looking at the hostname and user

modes_on(channel)
nick=(newnick)

The nick of a User may be changed freely, but it must not contain glob patterns.

replace(other)

We can replace everything at once with data from another User

to_irc_user(opts={})

Since to_irc_user runs the same checks on server and channel as to_irc_netmask, we just try that and return self if it works.

Subclasses of User will return self if possible.

user=(newuser)

We have to allow changing the user of an Irc User due to some networks (e.g. Freenode) changing hostmasks on the fly. We still check if the new user data has glob patterns though.

[Validate]