Perlmod outputs PutUser before triggered command (OnChanMsg) #225

Closed
opened 2026-10-05 04:06:14 +02:00 by adam · 1 comment
Owner

When creating a perlmodule I would like to trigger a message back to the channel, but for some reason the PutUser is displayed BEFORE the message which triggered the function itself. I developed a hack to get around that (since PutIRC does not display on the user hosting the script) but it involves printing the triggering message manually, then sending a HALTCORE back to znc.

I have attached the function, but perhaps I am just doing something wrong. If this is the intended functionality then sorry for bothering you!

sub OnChanMsg {
    my $self = shift;
    my ($nick, $chan, $msg) = @_;

    if($chan->GetName eq "#vong"){
                #log to module.
                #$self->PutModule("Hey, ".$nick->GetNick." said [$msg] on ".$chan->GetName);
                my $replyString="Channel: ".$chan->GetName." , Message: ".$msg." , Nick: ".$nick->GetNick." , Hosted by ".$varrrr;
                #$self->GetUser->GetNick; # user account
                $self->PutIRC("PRIVMSG ".$chan->GetName." :".$replyString); #send the reply to the user's query
                $self->PutUser(":".$nick->GetNick." PRIVMSG ".$chan->GetName." :".$msg); #print the users message locally
                $self->PutUser(":".$self->GetNetwork->GetCurNick."* PRIVMSG ".$chan->GetName." :".$replyString); #then the reply locally

                return $ZNC::HALTCORE; #and tell ZNC not to post the message, as I did already  If you dont do it this way it will put the reply before the message
                #return $ZNC::CONTINUE;
        }else{
                return $ZNC::CONTINUE;
        }
}
When creating a perlmodule I would like to trigger a message back to the channel, but for some reason the PutUser is displayed BEFORE the message which triggered the function itself. I developed a hack to get around that (since PutIRC does not display on the user hosting the script) but it involves printing the triggering message manually, then sending a HALTCORE back to znc. I have attached the function, but perhaps I am just doing something wrong. If this is the intended functionality then sorry for bothering you! ``` perl sub OnChanMsg { my $self = shift; my ($nick, $chan, $msg) = @_; if($chan->GetName eq "#vong"){ #log to module. #$self->PutModule("Hey, ".$nick->GetNick." said [$msg] on ".$chan->GetName); my $replyString="Channel: ".$chan->GetName." , Message: ".$msg." , Nick: ".$nick->GetNick." , Hosted by ".$varrrr; #$self->GetUser->GetNick; # user account $self->PutIRC("PRIVMSG ".$chan->GetName." :".$replyString); #send the reply to the user's query $self->PutUser(":".$nick->GetNick." PRIVMSG ".$chan->GetName." :".$msg); #print the users message locally $self->PutUser(":".$self->GetNetwork->GetCurNick."* PRIVMSG ".$chan->GetName." :".$replyString); #then the reply locally return $ZNC::HALTCORE; #and tell ZNC not to post the message, as I did already If you dont do it this way it will put the reply before the message #return $ZNC::CONTINUE; }else{ return $ZNC::CONTINUE; } } ``` <!-- github-sync-id:13846694 -->
adam closed this issue 2026-10-05 04:06:14 +02:00
Author
Owner

This is expected behaviour, PutIRC goes to the server, PutUser goes to user's clients.

Feel free to ask questions about the API on #znc on freenode/efnet.

This is expected behaviour, PutIRC goes to the server, PutUser goes to user's clients. Feel free to ask questions about the API on #znc on freenode/efnet. <!-- github-comment-id:17283182 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#225