Procházet zdrojové kódy

Some updates to !lag.

tags/v0.1^2
Ben Kurtovic před 12 roky
rodič
revize
7d52d4558a
2 změnil soubory, kde provedl 18 přidání a 6 odebrání
  1. +17
    -5
      earwigbot/commands/lag.py
  2. +1
    -1
      earwigbot/wiki/copyvios/parsers.py

+ 17
- 5
earwigbot/commands/lag.py Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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):


Načítá se…
Zrušit
Uložit