Sfoglia il codice sorgente

Some updates to !lag.

tags/v0.1^2
Ben Kurtovic 12 anni fa
parent
commit
7d52d4558a
2 ha cambiato i file con 18 aggiunte e 6 eliminazioni
  1. +17
    -5
      earwigbot/commands/lag.py
  2. +1
    -1
      earwigbot/wiki/copyvios/parsers.py

+ 17
- 5
earwigbot/commands/lag.py Vedi File

@@ -32,12 +32,24 @@ class Lag(Command):
site = self.get_site(data)
if not site:
return

msg = "\x0302{0}\x0F: Toolserver replag is {1}; database maxlag is {2}."
replag, maxlag = site.get_replag(), site.get_maxlag()
msg = msg.format(site.name, self.format(replag), self.format(maxlag))
if self.command == "replag":
base = "\x0302{0}\x0F: {1}."
msg = base.format(site.name, self.get_replag(site))
elif self.command == "maxlag":
base = "\x0302{0}\x0F: {1}."
msg = base.format(site.name, self.get_maxlag(site).capitalize())
else:
base = "\x0302{0}\x0F: {1}; {2}."
msg = base.format(site.name, self.get_replag(site),
self.get_maxlag(site))
self.reply(data, msg)

def get_replag(self, site):
return "Toolserver replag is {0}".format(self.time(site.get_replag()))

def get_maxlag(self, site):
return "database maxlag is {0}".format(self.time(site.get_maxlag()))

def get_site(self, data):
if data.kwargs and "project" in data.kwargs and "lang" in data.kwargs:
project, lang = data.kwargs["project"], data.kwargs["lang"]
@@ -76,7 +88,7 @@ class Lag(Command):
return
return site

def format(self, seconds):
def time(self, seconds):
parts = [("year", 31536000), ("day", 86400), ("hour", 3600),
("minute", 60), ("second", 1)]
msg = []


+ 1
- 1
earwigbot/wiki/copyvios/parsers.py Vedi File

@@ -71,7 +71,7 @@ class ArticleTextParser(BaseTextParser):
"""
wikicode = mwparserfromhell.parse(self.text)
clean = wikicode.strip_code(normalize=True, collapse=True)
self.clean = clean.replace("\n\n", "\n") # Collapse extra newlines.
self.clean = clean.replace("\n\n", "\n") # Collapse extra newlines
return self.clean

def chunk(self, nltk_dir, max_chunks, max_query=256):


Caricamento…
Annulla
Salva