3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-28 21:52:38 +01:00
dbot/modules/users
2013-10-23 11:41:22 +00:00
..
api.js ok i fixed it 2013-08-30 02:55:20 +00:00
commands.js [Close #595] 2013-10-23 11:41:22 +00:00
config.json Build help link automatically [#439] 2013-05-17 07:34:25 +00:00
pages.js Automatically look for modules with root indexes and show those on the index [Close #427] 2013-04-30 19:33:26 +00:00
README.md create ~removealias command [Close #549] 2013-08-17 17:23:43 +00:00
strings.json more translations from gian-maria.daffre@giammi.com 2013-08-31 19:58:17 +00:00
usage.json create ~removealias command [Close #549] 2013-08-17 17:23:43 +00:00
users.js fix for currentnick 2013-08-29 20:07:30 +00:00

Users

Track users.

Description

This module tracks users and their aliases through nick changes and all that kind of thing. Its mainly a utility module for other modules to use.

Commands

~alias [user]

If an alias is provided, this command will return the primary user for which this is an alias for. If a primary user is provided, it will return a confirmation of this fact and a count of how many aliases belong to the user.

~setaliasparent [newparent]

Set a nick which is currently serving as an alias to the primary user, while setting what was previously the primary user as an alias of the new primary user. Requires moderator level access by default.

~mergeusers [primaryuser] [secondaryuser]

This command merges two nicks which are recorded as primary users into one user. The secondary user and all of their aliases will be merged under primaryuser. Requires moderator level access by default.

~addalias [user] [alias]

Manually add alias to user.

~removealias [alias]

Remove alias from user.

API

resolveUser(server, nick, callback)

This resolves a given nick to its primary user, returning false if no user record is found in the store associated with the given nickname (either as a primary nick or an alias). The callback is called with one argument, a user object or false if no user was found.

getUser(uuid, callback)

Get a user by its uuid. Callback is called with one argument, a user object or false if no user was found by that uuid.

getChannel(server, channelName, callback)

This resolves a given server and channel name to a particular channel. The callback is called with one argument, a channel object or false if no channel was found with the given name on the given server.

getRandomChannelUser(server, channel, callback)

Given a server name and a channel name, this gets a random user from that channel. Callback is called with one argument, a user object or false if no channel was found from the given parameters.

getAllusers(callback)

Get a list of all users the bot currently knows about. Callback is called with one argument, a list of user records.

isOnline

Is the given nick on the given server currently in the given channel. Callback is called with one argument, a boolean as to whether the nick is currently in the specified place.

Data

User Object

{
    id: user uuid,
    primaryNick,
    currentNick: Current or last used nickname,
    server,
    channels: A list of names for channels this user has been in,
    aliases: A list of known aliases for this user
}

Channel Object

{
    id: channel uuid,
    server,
    name,
    users: A list of the uuids of users who are in this channel
}

Events

new_user(user)

This is executed when a new user is added to the known users DB.

new_user_alias(user, newNick)

When a new user alias is added.

new_channel(channel)

Executed when DBot creates a new channel object.

new_channel_user(user, channel)

Executed when DBot creates a new channel object.