Reinn Posted November 28, 2009 Share Posted November 28, 2009 (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... expandcollapse popupHotKeySet("{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 November 29, 2009 by Reinn Link to comment Share on other sites More sharing options...
BrettF Posted November 29, 2009 Share Posted November 29, 2009 Sample log file would help. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Reinn Posted November 29, 2009 Author Share Posted November 29, 2009 Added a sample of the logfile... Link to comment Share on other sites More sharing options...
Reinn Posted December 5, 2009 Author Share Posted December 5, 2009 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... Link to comment Share on other sites More sharing options...
Reinn Posted December 11, 2009 Author Share Posted December 11, 2009 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 .. Link to comment Share on other sites More sharing options...
Authenticity Posted December 11, 2009 Share Posted December 11, 2009 expandcollapse popupHotKeySet("{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 Link to comment Share on other sites More sharing options...
KaFu Posted December 11, 2009 Share Posted December 11, 2009 [autoit] Baaadaaaboooommmm ... Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Reinn Posted December 13, 2009 Author Share Posted December 13, 2009 expandcollapse popupHotKeySet("{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 Link to comment Share on other sites More sharing options...
Authenticity Posted December 13, 2009 Share Posted December 13, 2009 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. Link to comment Share on other sites More sharing options...
Reinn Posted December 13, 2009 Author Share Posted December 13, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now