Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a very basic problem with Net::IRC and that is determining what channel a /msg came from when the script sees it.

The goal of the script is to run a the only operator in a channel and provide some basic commands to users that have logged into it, on a private IRC server. Basically, for security no one can log as a privlaged user (all ports are set to i instead of I). Those that validate with the bot gain access to /kick /help and /times which posts the current local time.

However to make it work, they have to msg the bot (/msg botname kick username) ... but I haven't found an easy way to know which channel the /msg has come from. ($event->to)[0] is the bots name in this case ... is there a way to grab the channel as well?

Replies are listed 'Best First'.
Re: net::irc, channel name
by Malach (Scribe) on Feb 14, 2002 at 22:03 UTC

    A channel doesn't send the /msg, the user does.. as such it's not obvious which channel a user is in when they message the bot.

    What you may be able to do is effectively /whois the user and see what channel(s) they are on. However deciding which channel they're referring to (if they're on multiple) could be confusing.

    I'd suspect that it'd be simpler to get the user to specify the channel that they want to kick someone from, then verify that they are on that channel and authorised to do so.

    Caveat: I'm not a Net::IRC expert, but I use IRC a lot

    :)

    Malach
    So, this baby seal walks into a club.....