Jump to content

IRC ChannelBot Authhost


phew
 Share

Recommended Posts

hi!

i am trying to write my own IRC-Channel-Service bot in autoit!

just i get a problem to use an authhost-matching so i.e. only the user with the host

*!*@hostname.com

can send commands like ".say test" (makes the bot say "test") and stuff.

here is a part of my code:

While (1)
    $msg = GUIGetMsg()
    Select
    Case $msg = $quit
        ExitLoop
    EndSelect
    
    If $start = 1 Then
        $srcv = TCPRecv($socket, 512)
        If ($srcv <> "") Then
            doStart($srcv, $socket)
            PingPong($srcv, $socket)
            doVarClean()
        EndIf
    EndIf
WEnd

i am not too good with regexp so a friend helped me:

$auth = StringRegExp($srcv, ';).*?)!(.*?)@(.*?) (.*?) (.*?) :P.*)', 1)

(should be working for grab the hostname from the RAW)

RAW in IRC looks like: <- :nick!ident@hostname.com PRIVMSG #chan :text

my authhost is set on top of the script: Global Const $authhost = "@hostname.com"

so i guess i have to check if $auth = $authhost and if that is true, the bot shall execute the command, if $authhost <> $auth it should not do anything.

i think i have to set it somewhere into this peace of code:

If ($srcv <> "") Then
            doStart($srcv, $socket)
            PingPong($srcv, $socket)
            doVarClean()
        EndIf

but i have not even a clue how to get startet with grabbing the host from $srcv which is receiving all the RAW stuff.

i know its kinda bad description but perhaps someone can help :)

thanks!

Link to comment
Share on other sites

  • Moderators

You can't compare a var to an array as you did... $authhost <> $auth << using regexp's $auth should be an array... $authhost <> $auth[0] would be proper.

Your RegExp is not right either if I'm understanding what you are trying to do... Looks like you want the entire thing (not in bits).

So this:

$auth = StringRegExp($srcv, ':(.*?)!(.*?)@(.*?) (.*?) (.*?) sad.gif.*)', 1)oÝ÷ Ùj.Ùh¢K(ëax%GºÚ"µÍÌÍØ]]HÝ[ÔYÑ^
    ÌÍÜÜÝ  ][ÝÊÜÊIÌLÎÉÌLÉÌÌÎËÉÌLÐÉÌLËÛÛJI][ÝËJ
I would think.

About the other stuff... I have no idea what you are saying or asking.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You can't compare a var to an array as you did... $authhost <> $auth << using regexp's $auth should be an array... $authhost <> $auth[0] would be proper.

Your RegExp is not right either if I'm understanding what you are trying to do... Looks like you want the entire thing (not in bits).

So this:

$auth = StringRegExp($srcv, ':(.*?)!(.*?)@(.*?) (.*?) (.*?) sad.gif.*)', 1)oÝ÷ Ùj.Ùh¢K(ëax%GºÚ"µÍÌÍØ]]HÝ[ÔYÑ^
    ÌÍÜÜÝ  ][ÝÊÜÊIÌLÎÉÌLÉÌÌÎËÉÌLÐÉÌLËÛÛJI][ÝËJ
I would think.

About the other stuff... I have no idea what you are saying or asking.

thanks, i think you already answered what i needed :)

someone could remove smileys on CODE /CODE bb-codes?

Link to comment
Share on other sites

You could look at my IRC Bot in my signature for a base for the bot.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...