Net::Vypress::Chat - Perl extension for Vypress Chat protocol
use Net::Vypress::Chat; my $vyc = Net::Vypress::Chat->new( 'localip' => '192.168.0.1', 'debug' => 0 ); # This causes to shut down properly on kill signals. $SIG{INT} = sub { $vyc->shutdown() }; $SIG{KILL} = sub { $vyc->shutdown() }; $vyc->nick('some_nick'); $vyc->startup; # Anything goes here. $vyc->msg("person", "message"); $vyc->shutdown;
Net::Vypress::Chat provides API for using vypress chat functions like sending messages, setting topics and so on. It is also capable of recognising incoming UDP message type and returning information from it.
Net::Vypress::Chat is object oriented module and can only be used this way. What's about recognise() function i tried to stay as consistent as i can, but some values are mixed up. Module has these methods:
Initialises new instance of module. Sets these variables (if not explained: 0 - off, 1 - on):
0 - not active;
1 - active;
0 - male
1 - female
0 - Active
1 - Do Not Disturb
2 - Away
3 - Offline
0 - no debug
1 - actions level.
2 - protocol level.
Reinitialises userlist, but leaves information about self.
E.g.: $vyc->init_users();
Function to change network/port combination on the fly.
E.g.: $vyc->change_net(8168, '10.0.0.1');
Changes your nickname that is being held in $object->{'nick'}. Truncates it to 20 characters (maximum in protocol) and broadcasts it if module is initialised.
E.g.: $vyc->nick("SimpleGuy");
Translates numeric status to word status. Mainly used in module itself.
E.g.: $vyc->num2status(0) would return Available.
Does same as num2status(), but with active state.
E.g.: $vyc->num2active(1) would return Active.
Asks who is here in LAN. Used to build user lists.
E.g.: $vyc->who();
Sends remote execution request.
E.g.: $vyc->remote_exec("OtherGuy", "iexplore.exe", "secret");
Returns execution status to requester.
E.g.: $vyc->remote_exec_ack('OtherGuy', 'Some text');
Send sound request to channel.
E.g.: $vyc->sound_req("#Main", 'clap.wav');
Send chat string to channel in /me fashion.
E.g.: $vyc->me("#Main", "jumps around.");
Sends chat string to channel.
E.g.: $vyc->chat("#Main", "Hello!");
Joins channel and adds it to channel list.
E.g.: $vyc->join("#Main");
Parts channel and deletes it from channel list.
E.g.: $vyc->part("#Main");
Changes topic on channel. Adds your nick in ().
E.g.: $vyc->topic("#Main", "Hi folks") would give this topic - "Hi folks (SimpleGuy)".
Sends message to person.
E.g.: $vyc->msg("John", "Hello there...");
Sends message to all people in userlist. The message is marked as multi-user message.
E.g.: $vyc->mass("Hi everyone, I'm back.");
Sends message to people in array. The message is marked as multi-user message.
E.g.: $vyc->mass(('John', 'Paul'), "Hi everyone, I'm back.");
Changes your status into one of four states mentioned in new() and sets your autoanswer to messages.
E.g.: $vyc->status(0, "I like core dumps (C) zed");
Sets your activity. See new().
E.g.: $vyc->active(1);
Beeps user.
E.g.: $vyc->beep('OtherGuy');
Requests channel list. Todo: Maybe specification is bad? Don't use it for now.
E.g.: $vyc->chanlist();
Asks user to give his information.
E.g.: $vyc->info("John");
Sends user your information.
E.g.: $vyc->info_ack("John");
By default module sends following information automatically whenever requested by another client (see new()):
If you turn off send_info variable (see new()) module won't send any information automatically. Then you can access this method to generate answer for information request.
Channels variable can have these values:
1 - send actual channel list
0 - send nothing but #Main
array - array of channels.
E.g.: $vyc->info_ack("John", "made.up.host", "user", "1.2.3.4", "autoanswer", ('#Main'));
Joins to private chat.
E.g.: $vyc->pjoin("John");
Parts private chat.
E.g.: $vyc->ppart("John");
Sends string to private chat.
E.g.: $vyc->pchat("John", "Some message");
Sends /me action to private chat.
E.g.: $vyc->pme("John", "Some action");
Initialises two sockets (send and listen) for sending UDP messages and getting them. Also joins channel #Main and requests who list.
E.g.: $vyc->startup;
Ends module job. Exits all channels and closes all sockets.
E.g.: $vyc->shutdown();
Checks if you are on some specific channel.
E.g.: $vyc->on_chan("#Main") would return 1.
Checks if someone are on some specific channel.
Checks if you are in private chat with someone.
E.g.: $vyc->on_priv("John") would return 1 if you were in chat with John.
Checks if user is in userlist.
E.g.: $vyc->on_userlist("Dude") would return 1 if Dude would be logged in.
Returns array containing all channels user is on.
E.g.: @chans = $vyc->get_chans('John');
Reads socket and recognises string it received. Returns array. See recognise().
E.g.:
while (my @args = $vyc->readsock()) { # Remove first array element. my $packet_type = shift @args; if ($packet_type eq 'msg') { my ($from, $message) = @args; } }
Recognises string in a buffer if it is Vypress Chat protocol command. Returns type of command and its arguments. Also executes actions when needed.
Values are returned in array. First value will always be type of command. Other values may differ. Possible values are:
Returns: "who", $updater.
Returns: "who_ack", $from, $status, $active
Returns: "chat", $chan, $from, $text
Returns: "nick", $oldnick, $newnick
Returns: "join", $from, $chan, $status
Returns: "part", $who, $chan
Returns: "msg", $from, $text
Returns: "mass", $from, $text
Returns: "msg_ack", $from, $aa, $status, $gender
Returns: "remote_exec", $who, $command, $password
Returns: "remote_exec_ack", $from_who, $execution_text
Returns: "me", $chan, $fromwho, $text
Returns: "topic", $chan, $topic
Returns: "statuschange", $status, $aa
Returns: "info", $from
Returns: "info_ack", $from, $host, $user, $ip, $aa, @chans
Returns: "beep", $from
Returns: "beep_ack", $from, $gender
Returns: "sound_req", $from, $filename, $channel
Returns: "pjoin", $from
Returns: "ppart", $from
Returns: "pchat", $from, $text
Returns: "pme", $from, $text
Returns: "here", $fromwho, $chan
Returns: "here_ack", $from, $chan, $active
Returns: "active", $fromwho, $active
Userlist for channel is stored in $vyc->{channels}{$chan}{users}. It's an array.
IO::Socket IO::Socket::Inet IO::Select
Official web page of Vypress Chat: http://vypress.com/products/chat/
Artūras Šlajus, <x11@h2o.sky.lt>
Copyright 2003 by Artūras Šlajus
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Artūras'. Assuming UTF-8
To install Net::Vypress::Chat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Vypress::Chat
CPAN shell
perl -MCPAN -e shell install Net::Vypress::Chat
For more information on module installation, please visit the detailed CPAN module installation guide.