Jump to content

TheDcoder's IRC UDF: Full Compliance with RFC 2812 and IRCv3.1


TheDcoder
 Share

Recommended Posts

Hello! I have been busy with establishing the IRC Community for AutoIt... I thought that ##AutoIt needs a bot with lot of neat features, I made a simple one using @rcmaehl's UDF but it lacked many features which I wanted so I made a new UDF for myself lol.

Features:

  1. Lightweight & Simple.
  2. Native support for logging.
  3. Full compliance with RFC 2812 and IRCv3.1.
  4. Fully tested.
  5. Ability to parse server messages.
  6. Open source and Unlicenced.
  7. Coded with Best Coding Practices in mind.
  8. Support for major IRC networks.
  9. SASL Authentication Supported!

..etc.

Planned Features:

  1. Support for DCC and Direct P2P file transfer
  2. Colors
  3. More functions for Atheme services (NickServ, ChanServ etc.)

...etc.

Download

 

GitHub

https://github.com/TheDcoder/IRC-UDF-for-AutoIt

Enjoy! TD :D

 

P.S I am newbie at GitHub so the repo might look weird :P

Edited by TheDcoder
Added links

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Suggestion: Any UDF function that has a loop in it that, on rare occasions, it could get permanently stuck in should have a timeout and report failure when it does.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

@rcmaehl I check all my loops, all of them have error checking implemented and there is no chance that they could get stuck ;)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • 1 year later...

Thanks @TheDcoder:)

Here is an example of the UDF usage to connect to a twitch chat channel and send a message with a hotkey (as someone requested on the support forum):

#include <IRC.au3>
#include <Misc.au3>

; Allow some TCP lag
Opt("TCPTimeout", 500)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Twitch chat hotkey", 381, 436, 192, 124)
GUISetFont(10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Twitch chat hotkey", 128, 8, 153, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Twitch username:", 16, 88, 144, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 176, 88, 185, 24)
$Label3 = GUICtrlCreateLabel("OAuth password:", 16, 128, 141, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("oauth:", 176, 128, 185, 24)
$Button1 = GUICtrlCreateButton("Get OAuth password", 88, 176, 201, 41)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Twitch channel:", 16, 240, 128, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("kolento", 160, 240, 201, 24)
$Label5 = GUICtrlCreateLabel("Message:", 16, 288, 81, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input4 = GUICtrlCreateInput("Kappa hello guys Kappa", 112, 288, 249, 24)
$Button2 = GUICtrlCreateButton("Connect", 104, 376, 193, 41)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Status: disconnected", 136, 336, 128, 20)
GUICtrlSetColor(-1, 0xFF0000)
$Label7 = GUICtrlCreateLabel("Press F10 once connected to send the message", 56, 48, 291, 20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;restore previous values if the software has already been used

if RegRead("HKCU\Software\TwitchChatHotkey", "username") <> "" Then

    GUICtrlSetData($Input1, RegRead("HKCU\Software\TwitchChatHotkey", "username"))
    GUICtrlSetData($Input2, RegRead("HKCU\Software\TwitchChatHotkey", "password"))
    GUICtrlSetData($Input3, RegRead("HKCU\Software\TwitchChatHotkey", "channel"))
    GUICtrlSetData($Input4, RegRead("HKCU\Software\TwitchChatHotkey", "message"))

EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ShellExecute("http://twitchapps.com/tmi/")
        Case $Button2
            GUICtrlSetState($Button2, $GUI_DISABLE)
            connect()
    EndSwitch
WEnd

Func connect()

    GUICtrlSetData($Label6, "Status: connecting...")
    GUICtrlSetColor($Label6, $COLOR_BLUE)

    $username = GUICtrlRead($Input1)
    $password = GUICtrlRead($Input2)
    $channel = StringLower(GUICtrlRead($Input3))
    $message = GUICtrlRead($Input4)

    ;backup info for future usage

    Regwrite("HKCU\Software\TwitchChatHotkey", "username", "REG_SZ", $username)
    Regwrite("HKCU\Software\TwitchChatHotkey", "password", "REG_SZ", $password)
    Regwrite("HKCU\Software\TwitchChatHotkey", "channel", "REG_SZ", $channel)
    Regwrite("HKCU\Software\TwitchChatHotkey", "message", "REG_SZ", $message)

    ;Start Up Networking
    TCPStartup()

    ; Connect to IRC. Send Password, if any. Declare User Identity.
    Local $Sock = _IRCConnect("irc.chat.twitch.tv", 6667, $username, 0, $username, $password)

    ; Prepare to Receive Data
    Local $sRecv = ""

    ; Start Loop
    While 1

        ; Receive Data
        $sRecv = _IRCGetMsg($Sock)
        ConsoleWrite($sRecv)

        ; Split Data into Commands and Parameters for Processing
        Local $sTemp = StringSplit($sRecv, " ")

        ; If Not Usable, then Skip this Data
        If $sTemp[0] <= 2 Then ContinueLoop

        ; Decide What To Do Based on Received Data
        Switch $sTemp[2]

            ; On Server Welcome
            Case $RPL_WELCOME

                ; Join channel
                _IRCChannelJoin($Sock, "#" & $channel)

                GUICtrlSetData($Label6, "Status: connected")
                GUICtrlSetColor($Label6, $COLOR_GREEN)

                While 1

                    If _IsPressed(79) Then

                        $message = GUICtrlRead($Input4)

                        _IRCRaw($Sock, "PRIVMSG #" & $channel & " :" & $message)

                        while _IsPressed(79)

                            ;do nothing when the key is kept pressed to avoid chat flood, so the message is only sent once

                        WEnd

                    endif

                    $nMsg = GUIGetMsg()

                    If $nMsg = $GUI_EVENT_CLOSE Then

                        ; Disconnect
                        _IRCDisconnect($Sock)

                        ; Shutdown Networking
                        TCPShutdown()

                        Exit

                    EndIf

                WEnd

        EndSwitch

    WEnd

EndFunc   ;==>connect

Compiled version here:  Twitch chat message hotkey.exe

Link to comment
Share on other sites

Hello @Neutro, Glad to see that you like the UDF :). Thanks for the example, but it isn't using this UDF, am I right?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

I think you found the wrong thread @Neutro, my functions follow the _IRC_xxx naming scheme ;). You might be using @rcmaehl's UDF, it has been around long before mine existed.

P.S Take a look at the list of functions in IRC.au3: https://github.com/TheDcoder/IRC-UDF-for-AutoIt/blob/master/IRC.au3

Edited by TheDcoder
Added P.S

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Ah yeah you're right :D

I thought it was since i found the UDF in the download page under your name here :

:D

Do you want me to remove my post then and put it somewhere else? :)

#edit: if your UDF is newer than @rcmaehl one's then maybe you should replace the download of the UDF i used by yours because it's the one that shows first in google :)

Edited by Neutro
Link to comment
Share on other sites

1 minute ago, Neutro said:

I thought it was since i found the UDF in the download page under your name here :

I named it "TheDcoder's IRC UDF" instead of IRC UDF because @rcmaehl's version already existed and didn't want to cause any confusion, looks like I have done the opposite :D

2 minutes ago, Neutro said:

Do you want me to remove my post then and put it somewhere else? :)

Your choice, I don't mind if it stays here. But I would recommend you to thank @rcmaehl in his thread and share the snippet there too.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

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

×
×
  • Create New...