Sign in to follow this  
Followers 0
Reinn

Duplicate problem

10 posts in this topic

#1 ·  Posted (edited)

Let's say that I have a log file, from a chatroom. In the chatroom people can request stuff, like proxylist, etc. I wanted to make a queue for the requests, so I just can have it runing, and then check it a few hours later, and who requested what, so I can forfill the requests fast.

Whenever someone wants to request, he types: "#Request proxylist" and it will look like this:

<User> #Request proxylist

And that is because we are using IRC. But that's not the point.

When I load the logfile, I want it to only show the results, when a "#Request" shows up, and I've done that.

Now I want it to see if the nick of the user that requested also shows up in posts that also include: "sent to", "left", "quit","Invalid" & "kicked". (Now here my problem starts... I think I should use _ArrayUnique & _ArrayDelete but I don't know how...)

If he is in any of these, the request has to be deleted from the queue.

So... Any ideas? Take a look at my code so far...

HotKeySet("{F5}", "CheckNew")
HotKeySet("{ESC}", "end")

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 600, 304, 198, 123);, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$MenuItem1 = GUICtrlCreateMenu("Help")
$MenuItem2 = GUICtrlCreateMenuItem("About...", $MenuItem1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 600, 300)
GUICtrlSetData($Edit1,"")
GUISetState(@SW_SHOW)
GuiCtrlSetState($Edit1, BitOR($WS_HScroll, $WS_VScroll))
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            MsgBox(0,"About...", "This script has been made by Reinn")
    EndSwitch
WEnd

Func CheckNew()
    GUICtrlSetData($Edit1, "")
    $Request = FileRead(C:\Users\User\AppData\mIRC\Log files\logfile.log)
    $Filter = "#request"
    
    ;This needs to be added in some way to delete duplicates:  $Array1 = _ArrayUnique($Filter)
    ;Same comment as above  _ArrayDelete($Filter2,0)
    
    $_Split = StringSplit($Request, Chr(10))
    
    For $i = 1 To $_Split[0]
        If $Request <> StringInStr($_Split[$i], $Filter) Then
            GUICtrlSetData($Edit1, $_Split[$i] & @CRLF, "|")
        Else
            If $_Split[$i] = "" Then
            Else
            EndIf
        EndIf
    Next
EndFunc
Func end()
    Exit
EndFunc
#requests.log.txt Edited by Reinn

Share this post


Link to post
Share on other sites



Added a sample of the logfile...

Share this post


Link to post
Share on other sites

BUMP... Isn't there anyone who knows how to do this? Or at least tell me this is impossible if it is, but I don't think so, I'm just not sure how to do it...

Share this post


Link to post
Share on other sites

BUMP yet again.. I know it's triple post, but I haven't gotten any help ;)

I hope you guys understand what I meant and are able to help me ..

Share this post


Link to post
Share on other sites

HotKeySet("{F5}", "CheckNew")
HotKeySet("{ESC}", "end")

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 600, 304, 198, 123);, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$MenuItem1 = GUICtrlCreateMenu("Help")
$MenuItem2 = GUICtrlCreateMenuItem("About...", $MenuItem1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 600, 300)
GUICtrlSetData($Edit1,"")
GUISetState(@SW_SHOW)
GuiCtrlSetState($Edit1, BitOR($WS_HScroll, $WS_VScroll))
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            MsgBox(0,"About...", "This script has been made by Reinn")
    EndSwitch
WEnd

Func CheckNew()
    GUICtrlSetData($Edit1, "")
    $Request = FileRead("logfile.log")
    $sPattern = "(?i)(?s)(<([^\r\n>]+)>\s+#request\s+[^\r\n]+)(?!(?:.*?\2\s+\([^)]+\)\s+(?:quit|left|invalid|kicked)|.*?sent to \2))"
    
    $aMatch = StringRegExp($Request, $sPattern, 3)
    If IsArray($aMatch) Then
        For $i = 0 To UBound($aMatch)-1 Step 2
            GUICtrlSetData($Edit1, $aMatch[$i] & @CRLF, 1)
        Next
    EndIf
EndFunc


Func end()
    Exit
EndFunc

Func _SingleMatch($sString, $sPattern)
    Local $aMatch = StringRegExp($sString, $sPattern, 1)
    
    If @error = 0 Then Return $aMatch[0]
    Return ""
EndFunc

Share this post


Link to post
Share on other sites

HotKeySet("{F5}", "CheckNew")
HotKeySet("{ESC}", "end")

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 600, 304, 198, 123);, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$MenuItem1 = GUICtrlCreateMenu("Help")
$MenuItem2 = GUICtrlCreateMenuItem("About...", $MenuItem1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 600, 300)
GUICtrlSetData($Edit1,"")
GUISetState(@SW_SHOW)
GuiCtrlSetState($Edit1, BitOR($WS_HScroll, $WS_VScroll))
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            MsgBox(0,"About...", "This script has been made by Reinn")
    EndSwitch
WEnd

Func CheckNew()
    GUICtrlSetData($Edit1, "")
    $Request = FileRead("logfile.log")
    $sPattern = "(?i)(?s)(<([^\r\n>]+)>\s+#request\s+[^\r\n]+)(?!(?:.*?\2\s+\([^)]+\)\s+(?:quit|left|invalid|kicked)|.*?sent to \2))"
    
    $aMatch = StringRegExp($Request, $sPattern, 3)
    If IsArray($aMatch) Then
        For $i = 0 To UBound($aMatch)-1 Step 2
            GUICtrlSetData($Edit1, $aMatch[$i] & @CRLF, 1)
        Next
    EndIf
EndFunc


Func end()
    Exit
EndFunc

Func _SingleMatch($sString, $sPattern)
    Local $aMatch = StringRegExp($sString, $sPattern, 1)
    
    If @error = 0 Then Return $aMatch[0]
    Return ""
EndFunc

Thanks Authenticity for your effort! It's logging great, but I've encountered a problem... After the thing that the person requested are sent out or w/e, they aren't deleted from the list. (I do press F5 again to refresh it, but it still has them on the list.) I don't know if I've written it before, and I don't know if this is a part of your script but if you made the "bot" look for the nick of the person that requested, if his nick was also involved with the frazes "Sent to", and all the others, he would be deleted from the list.. I know this might be pretty advanced, and thanks for your help so far. Even a hint or the name of the function I'd need would be helpful!

Reinn

Share this post


Link to post
Share on other sites

The CheckNew() function only updates the edit. If you want to delete the content, do as you did in your script, GUICtrlSetData($Edit1, "") and the rest of the function as it is. I don't see anything wrong with the pattern, if you have other cases you should consider them as well. Right now, all the pattern does is to search for #request followed by a user name, capture it only if the look ahead is not positive, e.g. there is no <username> blah proxylist followed by sent to username and the alternations.

Share this post


Link to post
Share on other sites

The CheckNew() function only updates the edit. If you want to delete the content, do as you did in your script, GUICtrlSetData($Edit1, "") and the rest of the function as it is. I don't see anything wrong with the pattern, if you have other cases you should consider them as well. Right now, all the pattern does is to search for #request followed by a user name, capture it only if the look ahead is not positive, e.g. there is no <username> blah proxylist followed by sent to username and the alternations.

Okey thanks for the help! I'll check it out myself ;)

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