Send args to hook command??

Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Send args to hook command??

Rocko

HI There.

I trying out my perl skills by writing a simple 'Hello' script .

I want to type /hello usersname  and have weechat display 'Hello username'.

But im having trouble on figuring out on how to send the username as a parameter/args. to the command.


This is my script:

weechat::register("test_perl", "acidblue", "0.1" , "GPL" , "" ,"" , "");
weechat::hook_command("hello","","","","", "say", ""); 

sub say {
    my ($buffer, $args) = @_;
    my $name;
    weechat::command($buffer, "/me says hello $name");
    return weechat::WEECHAT_RC_OK;
}

Please advise.




Virus-free. www.avast.com
Reply | Threaded
Open this post in threaded view
|

Re: Send args to hook command??

Nils G
Hello Rocko,

Am 06.11.19 um 18:31 schrieb Rocko:

> I trying out my perl skills by writing a simple 'Hello' script .
> I want to type /hello /usersname /and have weechat display 'Hello /username/'.

I guess you mean your nick on server.

my $name_of_server = "freenode";
my $name = weechat::info_get('irc_nick', $name_of_server);


PS: to give support is easier on freenode.#weechat ;-)

Reply | Threaded
Open this post in threaded view
|

Re: Send args to hook command??

Rocko

On 11/6/2019 10:08 AM, Nils G wrote:

> Hello Rocko,
>
> Am 06.11.19 um 18:31 schrieb Rocko:
>
>> I trying out my perl skills by writing a simple 'Hello' script .
>> I want to type /hello /usersname /and have weechat display 'Hello /username/'.
> I guess you mean your nick on server.
>
> my $name_of_server = "freenode";
> my $name = weechat::info_get('irc_nick', $name_of_server);
>
>
> PS: to give support is easier on freenode.#weechat ;-)


No, not my nick, the nick of of user in channel

I want to pass the name of a user in the channel to the command, not my
username.

/hello name_of_user_in_channel


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Reply | Threaded
Open this post in threaded view
|

Re: Send args to hook command??

Nils G
Hello Rocko,

Am 06.11.19 um 20:29 schrieb Rocko:

> No, not my nick, the nick of of user in channel
> I want to pass the name of a user in the channel to the command, not my username.
> /hello name_of_user_in_channel

weechat::register("test_perl", "acidblue", "0.1" , "GPL" , "" ,"" , "");
weechat::hook_command("hello","","","","", "say", "");

sub say {
    my ($data, $buffer, $args) = @_;
    weechat::command($buffer, "/me says hello $args");
    return weechat::WEECHAT_RC_OK;
}

Reply | Threaded
Open this post in threaded view
|

Re: Send args to hook command??

Rocko
Ah HA!

I forgot the $data part, was wondering why "/me says hello $args" wasn't
working.

Thanks..


On 11/6/2019 12:08 PM, Nils G wrote:

> Hello Rocko,
>
> Am 06.11.19 um 20:29 schrieb Rocko:
>
>> No, not my nick, the nick of of user in channel
>> I want to pass the name of a user in the channel to the command, not my username.
>> /hello name_of_user_in_channel
> weechat::register("test_perl", "acidblue", "0.1" , "GPL" , "" ,"" , "");
> weechat::hook_command("hello","","","","", "say", "");
>
> sub say {
>      my ($data, $buffer, $args) = @_;
>      weechat::command($buffer, "/me says hello $args");
>      return weechat::WEECHAT_RC_OK;
> }
>

--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus