Skip to content

Commit

Permalink
Bugfixes, detalles
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioFinale committed Mar 17, 2018
1 parent 983003a commit cc3aea4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
9 changes: 4 additions & 5 deletions AddTopic.vb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Bot.vb
Expand Up @@ -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
Expand All @@ -1109,7 +1107,6 @@ Namespace WikiBot
End If
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Return postreqreader.ReadToEnd

End Function

''' <summary>Realiza una solicitud de tipo POST a un recurso web y retorna el texto.</summary>
Expand Down
19 changes: 7 additions & 12 deletions Page.vb
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions PeriodiBOT_Tasks.vb
Expand Up @@ -27,18 +27,18 @@ 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))
Dim TimediffToMinutes As Integer = CInt(Math.Truncate(Timediff / 60))
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
Expand Down

0 comments on commit cc3aea4

Please sign in to comment.