kameloso.plugins.seen

The Seen plugin implements "seen"; the ability for someone to query when a given nickname was last encountered online.

We will implement this by keeping an internal long[string] associative array of timestamps keyed by nickname. Whenever we see a user do something, we will update his or her timestamp to the current time. We'll save this array to disk when closing the program and read it from file when starting it, as well as saving occasionally once every few minutes.

We will rely on the ChanQueryService to query channels for full lists of users upon joining new ones, including the ones we join upon connecting. Elsewise, a completely silent user will never be recorded as having been seen, as they would never be triggering any of the functions we define to listen to. (There's a setting to ignore non-chatty events, as we'll see later.)

kameloso does primarily not use callbacks, but instead annotates functions with UDAs of IRC event *types*. When an event is incoming it will trigger the function(s) annotated with its type.

Callback delegates and Fibers *are* supported, however. Event handlers can be annotated to be called from with in a fiber, and other fibers and delegates can be manually registered to process on incoming events, alternatively scheduled to a point in time with a reasonably high degree of precision.

Members

Classes

SeenPlugin
class SeenPlugin

This is your plugin to the outside world, usually the only thing publicly visible in the entire module. It only serves as a way of proxying calls to our top-level private functions, as well as to house plugin-specific and -private variables that we want to keep out of top-level scope for the sake of modularity. If the only state is in the plugin, several plugins of the same kind can technically be run alongside each other, which would allow for several bots to be run in parallel. This is not yet supported but there's fundamentally nothing stopping it.

Functions

loadSeen
void loadSeen(SeenPlugin plugin)

Given a filename, read the contents and load it into a RehashingAA!(long[string]) associative array, then returns it. If there was no file there to read, return an empty array for a fresh start.

onCommandSeen
void onCommandSeen(SeenPlugin plugin, IRCEvent event)

Whenever someone says "!seen" in a CHAN or a QUERY, and if CHAN then only if in a *home*, this function triggers.

onNamesReply
void onNamesReply(SeenPlugin plugin, IRCEvent event)

Catch a NAMES reply and record each person as having been seen.

onNick
void onNick(SeenPlugin plugin, IRCEvent event)

When someone changes nickname, update their entry in the array.

onQuit
void onQuit(SeenPlugin plugin, IRCEvent event)

When someone quits, update their entry with the current timestamp iff they already have an entry.

onSomeAction
void onSomeAction(SeenPlugin plugin, IRCEvent event)

Whenever a user does something, record this user as having been seen at the current time.

onWHOReply
void onWHOReply(SeenPlugin plugin, IRCEvent event)

Catches each user listed in a WHO reply and updates their entries in the seen users list, creating them if they don't exist.

onWelcome
void onWelcome(SeenPlugin plugin)

After we have registered on the server and seen the welcome messages, load our seen users from file. Additionally set up a fiber that periodically saves seen users to disk once every timeBetweenSaves seconds.

reload
void reload(SeenPlugin plugin)

Reloads seen users from disk.

saveSeen
void saveSeen(SeenPlugin plugin)

Save the passed seen users associative array to disk, in JSON format.

selftest
auto selftest(SeenPlugin _, Selftester s)

Performs self-tests against another bot.

teardown
void teardown(SeenPlugin plugin)

When closing the program or when crashing with grace, save the seen users array to disk for later reloading.

updateAllObservedUsers
void updateAllObservedUsers(SeenPlugin plugin)

Update all currently observed users.

updateUser
void updateUser(SeenPlugin plugin, string signed, long time, Flag!"skipModesignStrip" skipModesignStrip)

Update a given nickname's entry in the seen array with the passed time, expressed in UNIX time.

Manifest constants

omniscientChannelPolicy
enum omniscientChannelPolicy;

The ChannelPolicy annotation dictates whether or not an annotated function should be called based on the *channel* the event took place in, if applicable.

Mixins

__anonymous
mixin UserAwareness

UserAwareness is a mixin template; it proxies to a few functions defined in kameloso.plugins.common.awareness to deal with common book-keeping that every plugin *that wants to keep track of users* need. If you don't want to track which users you have seen (and are visible to you now), you don't need this.

__anonymous
mixin ChannelAwareness!omniscientChannelPolicy

Complementary to UserAwareness is ChannelAwareness, which will add in book-keeping about the channels the bot is in, their topics, modes, and list of participants. Channel awareness requires user awareness, but not the other way around.

__anonymous
mixin PluginRegistration!SeenPlugin

Mixes in a module constructor that registers this module's plugin to be instantiated as part of the program running.

Structs

SeenSettings
struct SeenSettings

We want our plugin to be *configurable* with a section for itself in the configuration file. For this purpose we create a "Settings" struct housing our configurable bits, which we already made an instance of in SeenPlugin.

Mixed In Members

From mixin UserAwareness

hasUserAwareness
enum hasUserAwareness;

Flag denoting that UserAwareness

has been mixed in.

onUserAwarenessQuitMixin
void onUserAwarenessQuitMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessQuit.

onUserAwarenessNickMixin
void onUserAwarenessNickMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessNick.

onUserAwarenessCatchTargetMixin
void onUserAwarenessCatchTargetMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessCatchTarget.

onUserAwarenessCatchSenderMixin
void onUserAwarenessCatchSenderMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessCatchSender.

onUserAwarenessNamesReplyMixin
void onUserAwarenessNamesReplyMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessNamesReply.

onUserAwarenessEndOfListMixin
void onUserAwarenessEndOfListMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onUserAwarenessEndOfList.

From mixin ChannelAwareness!omniscientChannelPolicy

hasChannelAwareness
enum hasChannelAwareness;

Flag denoting that ChannelAwareness has been mixed in.

onChannelAwarenessSelfjoinMixin
void onChannelAwarenessSelfjoinMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessSelfjoin.

onChannelAwarenessSelfpartMixin
void onChannelAwarenessSelfpartMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessSelfpart.

onChannelAwarenessJoinMixin
void onChannelAwarenessJoinMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessJoin.

onChannelAwarenessPartMixin
void onChannelAwarenessPartMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessPart.

onChannelAwarenessNickMixin
void onChannelAwarenessNickMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessNick.

onChannelAwarenessQuitMixin
void onChannelAwarenessQuitMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessQuit.

onChannelAwarenessTopicMixin
void onChannelAwarenessTopicMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessTopic.

onChannelAwarenessCreationTimeMixin
void onChannelAwarenessCreationTimeMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessCreationTime.

onChannelAwarenessModeMixin
void onChannelAwarenessModeMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessMode.

onChannelAwarenessWhoReplyMixin
void onChannelAwarenessWhoReplyMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessWhoReply.

onChannelAwarenessNamesReplyMixin
void onChannelAwarenessNamesReplyMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessNamesReply.

onChannelAwarenessModeListsMixin
void onChannelAwarenessModeListsMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessModeLists.

onChannelAwarenessChannelModeIsMixin
void onChannelAwarenessChannelModeIsMixin(IRCPlugin plugin, IRCEvent event)

Proxies to onChannelAwarenessChannelModeIs.

See Also

Meta