|
@@ -29,39 +29,41 @@ class Lag(Command): |
|
|
commands = ["lag", "replag", "maxlag"] |
|
|
commands = ["lag", "replag", "maxlag"] |
|
|
|
|
|
|
|
|
def process(self, data): |
|
|
def process(self, data): |
|
|
if data.kwargs and "project" in data.kwargs and "lang" in data.kwargs: |
|
|
|
|
|
project, lang = data.kwargs["project"], data.kwargs["lang"] |
|
|
|
|
|
site = self.get_site(data, project, lang) |
|
|
|
|
|
if not site: |
|
|
|
|
|
return |
|
|
|
|
|
elif data.args: |
|
|
|
|
|
if len(data.args) > 1: |
|
|
|
|
|
name = " ".join(data.args) |
|
|
|
|
|
self.reply(data, "unknown site: \x0302{0}\x0F.".format(name)) |
|
|
|
|
|
return |
|
|
|
|
|
name = data.args[0] |
|
|
|
|
|
if "." in name: |
|
|
|
|
|
lang, project = name.split(".")[:2] |
|
|
|
|
|
elif ":" in name: |
|
|
|
|
|
project, lang = name.split(":")[:2] |
|
|
|
|
|
else: |
|
|
|
|
|
try: |
|
|
|
|
|
site = self.bot.wiki.get_site(name) |
|
|
|
|
|
except exceptions.SiteNotFoundError: |
|
|
|
|
|
msg = "unknown site: \x0302{0}\x0F.".format(name) |
|
|
|
|
|
self.reply(data, msg) |
|
|
|
|
|
return |
|
|
|
|
|
site = self.get_site(data, project, lang) |
|
|
|
|
|
if not site: |
|
|
|
|
|
return |
|
|
|
|
|
else: |
|
|
|
|
|
site = self.bot.wiki.get_site() |
|
|
|
|
|
|
|
|
site = self.get_site(data) |
|
|
|
|
|
if not site: |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
msg = "\x0302{0}\x0F: Toolserver replag is {1} seconds; database maxlag is {2} seconds" |
|
|
|
|
|
|
|
|
msg = "\x0302{0}\x0F: Toolserver replag is {1} seconds; database maxlag is {2} seconds." |
|
|
msg = msg.format(site.name, site.get_replag(), site.get_maxlag()) |
|
|
msg = msg.format(site.name, site.get_replag(), site.get_maxlag()) |
|
|
self.reply(data, msg) |
|
|
self.reply(data, msg) |
|
|
|
|
|
|
|
|
def get_site(self, data, project, lang): |
|
|
|
|
|
|
|
|
def get_site(self): |
|
|
|
|
|
if data.kwargs and "project" in data.kwargs and "lang" in data.kwargs: |
|
|
|
|
|
project, lang = data.kwargs["project"], data.kwargs["lang"] |
|
|
|
|
|
return self.get_site_from_proj_and_lang(data, project, lang) |
|
|
|
|
|
|
|
|
|
|
|
if not data.args: |
|
|
|
|
|
return self.bot.wiki.get_site() |
|
|
|
|
|
|
|
|
|
|
|
if len(data.args) > 1: |
|
|
|
|
|
name = " ".join(data.args) |
|
|
|
|
|
self.reply(data, "unknown site: \x0302{0}\x0F.".format(name)) |
|
|
|
|
|
return |
|
|
|
|
|
name = data.args[0] |
|
|
|
|
|
if "." in name: |
|
|
|
|
|
lang, project = name.split(".")[:2] |
|
|
|
|
|
elif ":" in name: |
|
|
|
|
|
project, lang = name.split(":")[:2] |
|
|
|
|
|
else: |
|
|
|
|
|
try: |
|
|
|
|
|
return self.bot.wiki.get_site(name) |
|
|
|
|
|
except exceptions.SiteNotFoundError: |
|
|
|
|
|
msg = "unknown site: \x0302{0}\x0F.".format(name) |
|
|
|
|
|
self.reply(data, msg) |
|
|
|
|
|
return |
|
|
|
|
|
return self.get_site_from_proj_and_lang(data, project, lang) |
|
|
|
|
|
|
|
|
|
|
|
def get_site_from_proj_and_lang(self, data, project, lang): |
|
|
try: |
|
|
try: |
|
|
site = self.bot.wiki.get_site(project=project, lang=lang) |
|
|
site = self.bot.wiki.get_site(project=project, lang=lang) |
|
|
except exceptions.SiteNotFoundError: |
|
|
except exceptions.SiteNotFoundError: |
|
|