switching to DJabberd::Agent::Node for bot creation.
Martin Atkins
mart at degeneration.co.uk
Tue Feb 12 08:49:14 UTC 2008
Peter Brown wrote:
> hi again,
>
> i have switched to DJabberd::Agent::Node for my bot as it seems a bit
> more useful for what i need to do.
> but i have hit the same wall with MUC room creation.
>
> this is my handle_message function.
> sub handle_message {
> my ($self, $vhost, $stanza) = @_;
> my $default_intro = "for support type support\nfor admin type
> admin\nfor help type help";
> my $servername = $vhost->{server_name};
> my $from = $stanza->from_jid;
> my $to = $stanza->to_jid;
> my $username = $from->as_string;
> $username =~ s/\@.*$//;
>
> my $message = "";
> my $body = first { $_->element_name eq "body" }
> $stanza->children_elements;
> my $text = $body->first_child;
> $logger->debug("'$vhost': '$from' asking '$text'");
>
> if ($text eq "support") {
> # open chat room
> my $room = DJabberd::Plugin::MUC::Room->new($roomname,
> $servername, $vhost);
> # invite support staff to chat room
> } else {
> $message = $default_intro;
> }
>
> $message = $default_intro;
> my $response = $stanza->make_response();
> $response->set_raw("<body>".$message."</body>");
> $response->deliver($vhost);
> }
>
> the strange thing is it doesn't send any log messages which doesn't help
> me work out the problem.
> it doesn't get the same error as before but i can't see the room either.
>
I'm not really all that familiar with the MUC code, but I'd guess (from
a quick review of the plugin) that the Room constructor wants the vhost
with the MUC plugin in it, not the one with your bot. (Assuming that
they are different. I think they have to be.)
More information about the Djabberd
mailing list