Sign in to follow this  
Followers 0
Chris86

Mini IRC

3 posts in this topic

#1 ·  Posted (edited)

Hi, i have been working on an mini irc app, now im stuck :S i dont know how to make the script retriev messages from the server and put it in a message window. can some one help me?

the client:

#include <GUIConstants.au3>
#include <IRC.au3>
GUICreate("Mini IRC",500,300)

$filemenu = GuiCtrlCreateMenu ("Options")
$connectitem = GuiCtrlCreateMenuitem ("Connect",$filemenu)
$disconnectitem = GuiCtrlCreateMenuitem ("Disconnect",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("About")
$aboutitem = GuiCtrlCreateMenuitem ("Om Irc Mini",$helpmenu)

$okbutton = GuiCtrlCreateButton ("OK",50,130,70,20)

$cancelbutton = GuiCtrlCreateButton ("Cancel",180,130,70,20)
GUICtrlCreateLabel ("Nick:",  10, 5)
$nick = GUICtrlCreateInput ("", 45,  5, 100, 20)
$message = GUICtrlCreateLabel ("",  -1, 0); How can i make the messages get displayed?


Global $server = "irc.eu.gamesurge.net"
Global $port = 6667

GuiSetState()

While 1
    $msg = GUIGetMsg()
    

    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
            ExitLoop
        

        Case $msg = $exititem
            ExitLoop
        
        Case $msg = $okbutton
            MsgBox(0, "Click","You clicked OK!")

        Case $msg = $aboutitem
            Msgbox(0,"About","GUI Menu Test")
    EndSelect
WEnd

GUIDelete()

Exit

IRC.au3 (Include)

;===============================================================================
;
; 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
;
;===============================================================================
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)
    TCPSend($i, "USER " & $nick & " 0 0 " & $nick &@CRLF)
    Return $i
EndFunc

;===============================================================================
;
; Description:    Joins an IRC Channel
; Parameter(s):  $irc - Socket Identifer from _IRCConnect ()
;                  $chan - Channel you wish to join
; 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 _IRCJoinChannel ($irc, $chan)
    If $irc = -1 Then Return 0
    TCPSend($irc, "JOIN " & $chan & @CRLF)
    If @error Then 
        MsgBox(1, "IRC.au3", "Server has disconnected.")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Description:    Sends a message using IRC
; Parameter(s):  $irc - Socket Identifer from _IRCConnect ()
;                   $msg - Message you want to send
;                  $chan - Channel/Nick you wish to send to
; 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 _IRCSendMessage ($irc, $msg, $chan="")
    If $irc = -1 Then Return 0
    If $chan = "" Then
        TCPSend($irc, $msg & @CRLF)
        If @error Then 
            MsgBox(1, "IRC.au3", "Server has disconnected.")
            Return -1
        EndIf
        Return 1
    EndIf
    TCPSend($irc, "PRIVMSG " & $chan & " :" & $msg & @CRLF)
        If @error Then 
        MsgBox(1, "IRC.au3", "Server has disconnected.")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Description:    Changes a MODE on IRC
; Parameter(s):  $irc - Socket Identifer from _IRCConnect ()
;                   $mode - Mode you wish to change
;                  $chan - Channel/Nick you wish to send to
; 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 _IRCChangeMode ($irc, $mode, $chan="")
    If $irc = -1 Then Return 0
    If $chan = "" Then
        TCPSend($irc, "MODE " & $mode & @CRLF)
        If @error Then 
        MsgBox(1, "IRC.au3", "Server has disconnected.")
        Return -1
    EndIf
    Return 1
    EndIf
    TCPSend($irc, "MODE " & $chan & " " & $mode & @CRLF)
        If @error Then 
        MsgBox(1, "IRC.au3", "Server has disconnected.")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; 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
Edited by Chris86

Share this post


Link to post
Share on other sites



plzz

Share this post


Link to post
Share on other sites

Bump

Share this post


Link to post
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
Sign in to follow this  
Followers 0