| 1 | package AnySan::Receive; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | sub new { | ||
| 6 | my($class, %args) = @_; | ||
| 7 | bless { %args }, $class; | ||
| 8 | } | ||
| 9 | |||
| 10 | sub provider { $_[0]->{provider} } | ||
| 11 | sub event { $_[0]->{event} } | ||
| 12 | sub nickname { $_[0]->{nickname} } | ||
| 13 | sub from_nickname { $_[0]->{from_nickname} } | ||
| 14 | sub message { $_[0]->{message} } | ||
| 15 | |||
| 16 | sub attribute { | ||
| 17 | my($self, $name, $value) = @_; | ||
| 18 | return $self->{attribute}->{$name} = $value if defined $name && defined $value; | ||
| 19 | return $self->{attribute}->{$name} if defined $name; | ||
| 20 | return $self->{attribute}; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub send_reply { | ||
| 24 | my($self, $message) = @_; | ||
| 25 | $self->{cb}->( | ||
| 26 | reply => $message | ||
| 27 | ); | ||
| 28 | } | ||
| 29 | |||
| 30 | # for backward compatible | ||
| 31 | *send_replay = \&send_reply; | ||
| 32 | |||
| 33 | 1; | ||
| 34 | __END__ |