E2::Message - A module for accessing Everything2 messages
use E2::Message; my $catbox = new E2::Message; $catbox->login( "username", "password" ); # see E2::Interface $catbox->set_room( "Outside" ); # List public messages my @msg = $catbox->list_public; # Output the messages print "Public Messages:\n"; print "(Topic: " . $catbox->topic . ")\n"; foreach my $m (@msg) { print "$m->{author}: $m->{text}\n"; } # List unarchived private messages @msg = $catbox->list_private( 1 ); # Output the messages print "Private Messages:\n"; foreach my $m (@msg) { print "($m->{group}) " if $m->{group}; print "$m->{author}: $m->{text}\n"; }
This module provides an interface to http://everything2.com's messaging system (the chatterbox as well as private messages). It inherits E2::Ticker.
E2::Message fetches public and private messages from everything2.com. Subsequent calls to its list_public and list_private will return only new messages, unless the corresponding reset method has been called.
E2::Message
list_public
list_private
reset
new creates an E2::Message object that defaults to "Guest User" on E2 and, until login is called, can retrieve only public messages and can send neither public nor private messages.
new
login
This method returns the current public room's topic. This topic is updated as a side-effect to both list_public and set_room, so if neither of these methods have been called, topic will return undef.
set_room
topic
undef
This method returns the current room name.
This method returns the current room's node_id.
list_public fetches and returns any public messages in the current room that have been posted since the last call to list_public, as well as updating the topic, room, and room_id. It returns a list of hashrefs representing the fetched messages, each with the following keys:
author # Username of message author author_id # User_id of message author message_id # Id of message time # Timestamp of message text # Text of the message
list_public returns an empty list if no new messages exist.
Exceptions: 'Unable to process request', 'Parse error:'
list_private fetches and returns any private messages that have been posted sincethe last call to list_private. If DROP_ARCHIVED is true, only messages that do not have the 'archive' flag will be returned. This method returns a list of hashrefs representing the fetched messages, each with the following keys:
author # Username of message author author_id # User_id of message author id # Id of message time # Timestamp of message text # Text of the message archive # Boolean: Is this message archived? # The following only exist for # group messages group # Name of usergroup group_id # Id of usergourp grouptype # Type of usergroup
list_private returns an empty list if no new messages exist.
This method resets the public message ticker, so the next call to list_public will retrieve all available public messages (they will all be considered "unfetched").
This method resets the private message ticker, so that in the next call to list_private, all private messages will be considered "unfetched."
send sends "TEXT" as if it were entered into E2's chatterbox. This message need not be escaped in any way. It returns true on success and undef on failure.
send
Exceptions: 'Unable to process request'
blab sends the private "blab" message MESSAGE_TEXT to user_id RECIPIANT_ID. If CC is true, sends a copy of the message to the sender as well. Returns true on success and undef on failure.
blab
These methods archive, unarchive, or permanently delete the messages in MSG_ID_LIST (this is a list of message ids).
This method performs multiple archive, unarchive, and delete operations on a list of messages.
HASH is organized as a hash of msg_id => operation pairs. Example:
$catbox->perform( 100 => 'archive', 101 => 'unarchive', 102 => 'delete' );
If any operations besides "archive", "unarchive", and "delete" are specified, this method throws an "Invalid operation:" exception.
Exceptions: 'Unable to process request', 'Invalid operation:'
set_room changes the current public room to ROOM_NAME. It returns true on success, 0 if ROOM_NAME is already the current room, and undef on failure.
E2::Interface, E2::Ticker, http://everything2.com, http://everything2.com/?node=clientdev
Jose M. Weeks <jose@joseweeks.com> (Simpleton on E2)
This software is public domain.
To install E2::Interface, copy and paste the appropriate command in to your terminal.
cpanm
cpanm E2::Interface
CPAN shell
perl -MCPAN -e shell install E2::Interface
For more information on module installation, please visit the detailed CPAN module installation guide.