Jump to content

IRC UDF


McGod
 Share

Recommended Posts

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)

IRC.au3

UDF

Example.au3

Example Script.

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

8Ball.au3

8Ball Script.Quickly made up.

My 8ball.ini

[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
Link to comment
Share on other sites

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)

IRC.au3

UDF

Example.au3

Example Script.

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

Very very useful!

Good Job!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

But really cool and useful funcs. Thanks!

Edited by theguy0000

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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ÉtoÝ÷ ÚÚºÚ"µÍY   ÌÍÜÕ[ÌWHH  ][ÝÔSÉ][ÝÈ[ÒTÔ[Ê    ÌÍÜÛØÚË  ÌÍÜÕ[ÌJ

After these changes the script responded to pings just fine.

Edited by Obi-w00t
Link to comment
Share on other sites

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

Link to comment
Share on other sites

;===============================================================================
;
; 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!

Link to comment
Share on other sites

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

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][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

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...