From cc3aea40156702d4010b9a8504d6b0cf11690560 Mon Sep 17 00:00:00 2001 From: MarioFinale Date: Sat, 17 Mar 2018 14:33:25 -0300 Subject: [PATCH] Bugfixes, detalles --- AddTopic.vb | 9 ++++----- Bot.vb | 3 --- Page.vb | 19 +++++++------------ PeriodiBOT_Tasks.vb | 8 ++++---- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/AddTopic.vb b/AddTopic.vb index 0a85f8e..507f83b 100644 --- a/AddTopic.vb +++ b/AddTopic.vb @@ -60,9 +60,9 @@ Namespace WikiBot Next For Each g As String In EndList.Keys 'Por cada grupo en la lista - pagetext = pagetext & Environment.NewLine & "== " & g & "==" 'Añadir al texto el título + pagetext = pagetext & Environment.NewLine & "== " & g & "==" & Environment.NewLine 'Añadir al texto el título For Each t As String In EndList(g).Keys 'Por cada tema - pagetext = pagetext & Environment.NewLine & "=== " & t & " ===" 'Añadir el tema al texto + pagetext = pagetext & Environment.NewLine & "=== " & t & " ===" & Environment.NewLine 'Añadir al texto el título 'Añadir el tema al texto For Each l As String In EndList(g)(t) 'Por cada linea del tema pagetext = pagetext & Environment.NewLine & l Next @@ -162,16 +162,15 @@ Namespace WikiBot End If '---------- threadTitle = Regex.Replace(threadTitle, "<+.+?>+", "") 'Quitar etiquetas HTML - Dim ThreadLink As String = UrlWebEncode((PageTitle & "#" & threadTitle).Trim.Replace(" ", "_").Replace("'''", "").Replace("''", "")) 'Generar enlace al hilo específico + Dim threadTitleLink As String = UrlWebEncode(threadTitle.Trim.Replace(" ", "_").Replace("'''", "").Replace("''", "")) + Dim threadLink As String = PageTitle & "#" & threadTitleLink 'Generar enlace al hilo específico threadTitle = Regex.Replace(threadTitle, "\{{1,2}|\}{1,2}", "") 'Quitar plantillas Dim threadResume As String = String.Empty 'Inicializa el resumen del hilo Dim threadBytes As Integer = Encoding.Unicode.GetByteCount(t) 'Bytes del hilo - Log("get signature", "LOCAL", BOTName) Dim lastsignature As Date = _bot.FirstDate(t) 'Firma más antigua del hilo If lastsignature.Year = 9999 Then Continue For End If - Log("get subsection", "LOCAL", BOTName) Dim Subsection As String = "Miscelánea" If Regex.Match(PageTitle, "(\/Archivo\/.+?)(\/)").Success Then Subsection = Regex.Match(PageTitle, "(\/Archivo\/.+?)(\/)").Value.Trim("/"c).Split("/"c)(1) 'Café del archivado diff --git a/Bot.vb b/Bot.vb index 04c5d70..362d60f 100644 --- a/Bot.vb +++ b/Bot.vb @@ -1092,9 +1092,7 @@ Namespace WikiBot If Cookies Is Nothing Then Cookies = New CookieContainer End If - Dim tempcookies As CookieContainer = Cookies - Dim postreq As HttpWebRequest = DirectCast(HttpWebRequest.Create(pageURL), HttpWebRequest) postreq.Method = "GET" postreq.KeepAlive = True @@ -1109,7 +1107,6 @@ Namespace WikiBot End If Dim postreqreader As New StreamReader(postresponse.GetResponseStream()) Return postreqreader.ReadToEnd - End Function ''' Realiza una solicitud de tipo POST a un recurso web y retorna el texto. diff --git a/Page.vb b/Page.vb index b7d16d6..516c39a 100644 --- a/Page.vb +++ b/Page.vb @@ -558,7 +558,6 @@ Namespace WikiBot Dim querystring As String = "format=json&maxlag=5&action=query&prop=revisions" & UrlWebEncode("|") & "pageimages" & UrlWebEncode("|") & "categories" & UrlWebEncode("|") & "extracts" & "&rvprop=user" & UrlWebEncode("|") & "timestamp" & UrlWebEncode("|") & "size" & UrlWebEncode("|") & "content" & UrlWebEncode("|") & "ids" & "&exlimit=1&explaintext&exintro&titles=" & UrlWebEncode(pageName) - 'Fix temporal, un BUG en la api de Mediawiki provoca que los extractos en solicitudes POST sean distintos a los de GET Dim QueryText As String = _bot.GETQUERY(querystring) @@ -575,7 +574,6 @@ Namespace WikiBot Dim PExtract As String = "" Dim Rootp As String = "" Try - PageID = TextInBetween(QueryText, "{""pageid"":", ",""ns")(0) User = TextInBetween(QueryText, """user"":""", """,")(0) Timestamp = TextInBetween(QueryText, """timestamp"":""", """,")(0) @@ -587,17 +585,15 @@ Namespace WikiBot Log("Warning: The page '" & pageName & "' doesn't exist yet!", "LOCAL", BOTName) End Try - Try + If TextInBetween(QueryText, """pageimage"":""", """").Count >= 1 Then PageImage = TextInBetween(QueryText, """pageimage"":""", """")(0) + Else + Debug_Log("The page '" & pageName & "' doesn't have any thumbnail", "LOCAL", BOTName) + End If - For Each m As Match In Regex.Matches(QueryText, "title"":""[Cc][a][t][\S\s]+?(?=""})") - PCategories.Add(NormalizeUnicodetext(m.Value.Replace("title"":""", ""))) - Next - Catch ex As IndexOutOfRangeException - Log("Warning: The page '" & pageName & "' doesn't have any thumbnail!", "LOCAL", BOTName) - - End Try - + For Each m As Match In Regex.Matches(QueryText, "title"":""[Cc][a][t][\S\s]+?(?=""})") + PCategories.Add(NormalizeUnicodetext(m.Value.Replace("title"":""", ""))) + Next If Regex.Match(PTitle, "\/.+").Success Then Rootp = PTitle.Split("/"c)(0) @@ -628,7 +624,6 @@ Namespace WikiBot Function GetLastTimeStamp(ByVal pageName As String) As String Dim querystring As String = "format=json&maxlag=5&action=query&prop=revisions&rvprop=timestamp&titles=" & pageName Dim QueryText As String = _bot.POSTQUERY(querystring) - Try Return TextInBetween(QueryText, """timestamp"":""", """")(0) Catch ex As IndexOutOfRangeException diff --git a/PeriodiBOT_Tasks.vb b/PeriodiBOT_Tasks.vb index f707097..0477de6 100644 --- a/PeriodiBOT_Tasks.vb +++ b/PeriodiBOT_Tasks.vb @@ -27,8 +27,11 @@ Public Module PeriodiBOT_Tasks Dim LastEditUnix As Integer = CInt(TimeToUnix(LastEdit)) Dim ActualTimeUnix As Integer = CInt(TimeToUnix(actualtime)) - Dim Timediff As Integer = ActualTimeUnix - LastEditUnix + If Not OS.ToLower.Contains("unix") Then 'En sistemas windows hay una hora de desfase + Timediff = Timediff - 3600 + End If + Dim TriggerTimeDiff As Long = TimeStringToSeconds(UserDate) Dim TimediffToHours As Integer = CInt(Math.Truncate(Timediff / 3600)) @@ -36,9 +39,6 @@ Public Module PeriodiBOT_Tasks Dim TimediffToDays As Integer = CInt(Math.Truncate(Timediff / 86400)) Dim responsestring As String = String.Empty - Debug_Log("Timediff " & username & ": " & Timediff, "LOCAL", BOTName) - Debug_Log("Trigger Timediff " & username & ": " & TriggerTimeDiff, "LOCAL", BOTName) - If Timediff > TriggerTimeDiff Then If TimediffToMinutes <= 1 Then