Jump to content



Photo

IRC UDF


  • Please log in to reply
29 replies to this topic

#1 McGod

McGod

    Formerly Chip

  • Active Members
  • PipPipPipPipPipPip
  • 589 posts

Posted 31 March 2007 - 09:56 PM

A small UDF to connect to IRC using TCP Functions.

Please note, Every IRC server is slightly different you may need to tweak the Example.au3 for it to work.

Functions:
_IRCConnect ($server, $port, $nick)
_IRCJoinChannel ($irc, $chan)
_IRCSendMessage ($irc, $msg, $chan="")
_IRCChangeMode ($irc, $mode, $chan="")
_IRCPing($ret)

Attached File  IRC.au3   4.35K   2893 downloads
UDF

Attached File  Example.au3   3.51K   1836 downloads
Example Script.

In the Example Script there is a small thing on recieved messages.

Attached File  8Ball.au3   4.44K   1042 downloads
8Ball Script.Quickly made up.

My 8ball.ini
Plain Text         
[Reply] 1 = "As I see It, Yes" 2 = "It is certain" 3 = "It is decidedly so" 4 = "Most likely" 5 = "Outlook good" 6 = "Signs point to Yes" 7 = "Without a doubt" 8 = "YES" 9 = "Yes, definitely" 10 = "You may rely on it" 11 = "Ask again later" 12 = "Better not tell you now" 13 = "Cannot predict now" 14 = "Concentrate and ask again" 15 = "Don't count on it" 16 = "My reply is No" 17 = "My sources say No" 18 = "Outlook not so good" 19 = "Reply Hazy, Try again" 20 = "Very doubtful" 21 = "Not only no, but HELL No!" 22 = "Not only yes, but HELL Yes!" 23 = "You will regret it!" 24 = "Signs point to No" 25 = "Go away... I don't want you back!" 26 = "Well I love you, come back!" 27 = "What? Are you taking me as an 8 ball?" 28 = "Outlook is disturbing"

Edited by Chip, 03 April 2007 - 11:29 AM.






#2 Pascal257

Pascal257

    Prodigy

  • Active Members
  • PipPipPip
  • 158 posts

Posted 01 April 2007 - 04:32 PM

A small UDF to connect to IRC using TCP Functions.

Please note, Every IRC server is slightly different you may need to tweak the Example.au3 for it to work.

Functions:
_IRCConnect ($server, $port, $nick)
_IRCJoinChannel ($irc, $chan)
_IRCSendMessage ($irc, $msg, $chan="")
_IRCChangeMode ($irc, $mode, $chan="")
_IRCPing($ret)

Attached File  IRC.au3   4.35K   2893 downloads
UDF

Attached File  Example.au3   3.51K   1836 downloads
Example Script.

In the Example Script there is a small thing on recieved messages.

Very very useful!
Good Job!

#3 McGod

McGod

    Formerly Chip

  • Active Members
  • PipPipPipPipPipPip
  • 589 posts

Posted 01 April 2007 - 11:13 PM

Can anyone think of functions I could add? I can't think of any :whistle:

#4 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 02 April 2007 - 01:29 AM

have you tried tidy? some of your indentataion is wrong.

But really cool and useful funcs. Thanks!

Edited by theguy0000, 02 April 2007 - 01:29 AM.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#5 lolp1

lolp1

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 283 posts

Posted 02 April 2007 - 05:42 AM

A registers func would be cool, so I can use to to join channels you need to be registerd to join.

#6 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 02 April 2007 - 01:54 PM

A registers func would be cool, so I can use to to join channels you need to be registerd to join.

but not all networks/servers use nickserv, so it wouldn't work everywhere. Best to only make global use functions that always work on any server. A register one wouldn't do that.
The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#7 Miranda

Miranda

    Seeker

  • Active Members
  • 46 posts

Posted 02 April 2007 - 02:42 PM

I haven't given this a try yet, but I intend to.

the things off the top of my head would be:
-Keep alive connection (afaik if you do nothing the connection doesn't stay open forever)?
-send private messages (would allow registration or w/e on some networks)
-scan chat for keywords (would allow for commands/communication to be recieved, maybe directly launch functions that are declared in a seperate file?)
-perform on connect (mainly joining channels/registering)

please ignore if any/all of these functions already exist / arent necessary.

Thanks alot in advance, will give it a go tonight

#8 Pascal257

Pascal257

    Prodigy

  • Active Members
  • PipPipPip
  • 158 posts

Posted 02 April 2007 - 07:31 PM

I haven't given this a try yet, but I intend to.

the things off the top of my head would be:
-Keep alive connection (afaik if you do nothing the connection doesn't stay open forever)?
-send private messages (would allow registration or w/e on some networks)
-scan chat for keywords (would allow for commands/communication to be recieved, maybe directly launch functions that are declared in a seperate file?)
-perform on connect (mainly joining channels/registering)

please ignore if any/all of these functions already exist / arent necessary.

Thanks alot in advance, will give it a go tonight

I think if you take a look on the example.au3 you should see that many of those things can be written within your script.
Just hook the incoming messages from the server.

#9 McGod

McGod

    Formerly Chip

  • Active Members
  • PipPipPipPipPipPip
  • 589 posts

Posted 02 April 2007 - 07:52 PM

theguy0000: I've never tried Tidy maybe I should
lolp1:Those are server-specific functions, "NS ID Pass" or whatever you would use.
Miranda:
-PING Function, but yes if you don't response to the PING you get booted
- _IRCSendMessage ($irc, "Message", "User") It works since the only different in PRIVMSG is #Chan and User
- That would be in your script, this is just for connecting and interacting with server.
- You again would add those in right spot.

#10 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 02 April 2007 - 11:25 PM

theguy0000: I've never tried Tidy maybe I should

yes, it's built into scite, just open your script and Press Ctrl+T and it will fix indentation among other things, depending on your preferences.
The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#11 lolp1

lolp1

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 283 posts

Posted 03 April 2007 - 01:37 AM

I'm some what confused. How do you plan on responding to the ping?

#12 Pascal257

Pascal257

    Prodigy

  • Active Members
  • PipPipPip
  • 158 posts

Posted 03 April 2007 - 11:05 AM

I'm some what confused. How do you plan on responding to the ping?

;=============================================================================== ; ; Description:      Returns a PING to Server ; Parameter(s):     $irc - Socket Identifer from _IRCConnect () ;                   $ret - The end of the PING to return ; Requirement(s):   _IRCConnect () to be run ; Return Value(s):  On Success - 1 ;                   On Failure - -1 = Server disconnected. ; Author(s):        Chip ; Note(s):          English only ; ;=============================================================================== Func _IRCPing($ret)     If $ret = "" Then Return -1     TCPSend($irc, "PONG " & $ret & @CRLF)         If @error Then         MsgBox(1, "IRC.au3", "Server has disconnected.")         Return -1     EndIf     Return 1 EndFunc


--> If $sTemp[1] = "PING" Then _IRCPing($sTemp[2]); Checks for PING replys (There smaller then usual messages so its special!

~~~~PING~~~~ You recieves these at random to make sure your still online and not disconnected. SYNTAX: PING :Randomletters Usually a PING has random letters that you have to respond with. EXAMPLE: PING :29809dj0d You would respond with PONG 29809dj0d ~~~~~~~~~~~

This should answer your question

#13 lolwut

lolwut

    Seeker

  • New Members
  • 8 posts

Posted 09 April 2007 - 01:37 AM

Sorry to bump this topic, but is any way my bot can "read" commands I add, like !msg, or !time, so I can make an intelligent bot?

#14 lolwut

lolwut

    Seeker

  • New Members
  • 8 posts

Posted 09 April 2007 - 01:49 AM

Oh, thanks Chip! Btw great UDF, I'll credit you on that.

#15 Obi-w00t

Obi-w00t

    Wayfarer

  • Active Members
  • Pip
  • 64 posts

Posted 09 April 2007 - 01:51 PM

Very cool script, I just tried it out and it works a treat!

Edit: Sorry to keep editing my post but I just figured out why the script is not working for me, some bits are missing in the code. In IRC.au3 change this:

Func _IRCJoinChannel ($chan)ƒo݊÷ ÚÚºÚ"µÍ‘[˜ÈÒTÒ›Ú[Ú[›™[     ˆÌ ͎ژË    ˆÌ ͎ØÚ[Šƒo݊÷ Ø   ݊{ayìZš™^±Êâ¦Û…©àzØb±«­¢+Ù%˜€˜ŒÀÌØíÍQ•µÁlÅt€ô€™ÅÕ½ÐíA%9™ÅÕ½ÐìQ¡•¸}%I A¥¹œ ˜ŒÀÌØíÍQ•µÁlÉtƒo݊÷ ÚÚºÚ"µÍ’Yˆ  ˆÌ ͎ÜÕ[ÌWHH  œ][ÝÔS‘Éœ][ÝÈ[ˆÒTÔ[™Ê    ˆÌ ͎ÜÛØÚË ˆÌ ͎ÜÕ[̗J

After these changes the script responded to pings just fine.

Edited by Obi-w00t, 09 April 2007 - 02:05 PM.


#16 McGod

McGod

    Formerly Chip

  • Active Members
  • PipPipPipPipPipPip
  • 589 posts

Posted 10 April 2007 - 12:57 AM

:"> Whoops, it was a fast func. I upload a new vers in an hour.

#17 Blackstar

Blackstar

    Wayfarer

  • Active Members
  • Pip
  • 68 posts

Posted 10 April 2007 - 03:51 AM

;=============================================================================== ; ; Description:    Connects you to a IRC Server, and gives your chosen Nick ; Parameter(s):  $server - IRC Server you wish to connect to ;                  $port - Port to connect to (Usually 6667) ;                  $nick - Nick you choose to use (You can change later) ; Requirement(s):   TCPStartup () to be run ; Return Value(s):  On Success - Socket identifer ;                  On Failure - It will exit on error ; Author(s):        Chip ; Note(s):        English only ; ;===============================================================================



Could you please add the Version line in your code so I'll know I have older code and needs to download your updated code? Or even a date. thanks!

#18 mmavipc

mmavipc

    Spammer!

  • Banned (NOT IN USE)
  • 287 posts

Posted 10 April 2007 - 10:57 PM

Good job. But there's one thing you forgot. Ip spoof protection. That is where a server checks for a ip spoofer by sending a ping.

telnet output:

:irc.toontownmovie.com NOTICE AUTH :*** Looking up your hostname... :irc.toontownmovie.com NOTICE AUTH :*** Couldn't resolve your hostname; using yo ur IP address instead NICK lol PING :907F36E1


to pass the ip spoof test you must reply with: PONG numhere
E.G.
server sends: PING :907F36E1
client must send to pass test: PONG 907F36E1

i edited your _IRCConnect function for you :shocked:

Func _IRCConnect ($server, $port, $nick)     Local $i = TCPConnect(TCPNameToIP($server), $port)     If $i = -1 Then Exit MsgBox(1, "IRC.au3 Error", "Server " & $server & " is not responding.")     TCPSend($i, "NICK " & $nick & @CRLF)     $ping = tcprecv($i,2048)     if stringleft($ping,4) = "PING" Then         $pong = stringreplace($ping,"PING :","")         tcpsend($i,"PONG " & $pong & @LF)     EndIf     TCPSend($i, "USER " & $nick & " 0 0 " & $nick &@CRLF)     Return $i EndFunc

Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

#19 Obi-w00t

Obi-w00t

    Wayfarer

  • Active Members
  • Pip
  • 64 posts

Posted 11 April 2007 - 11:55 AM

I think that might just be you, mmavipc, I get the following response when using the script:

:irc.toontownmovie.com NOTICE AUTH :*** Looking up your hostname... :irc.toontownmovie.com NOTICE AUTH :*** Found your hostname PING :B9F31B30


#20 mmavipc

mmavipc

    Spammer!

  • Banned (NOT IN USE)
  • 287 posts

Posted 12 April 2007 - 05:57 AM

I think that might just be you, mmavipc, I get the following response when using the script:

:irc.toontownmovie.com NOTICE AUTH :*** Looking up your hostname... :irc.toontownmovie.com NOTICE AUTH :*** Found your hostname PING :B9F31B30

you still got the ip spoof protection
PING :B9F31B30

Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users