@@ -80,6 +80,8 @@ following attributes: | |||||
``"en"`` | ``"en"`` | ||||
- :py:attr:`~earwigbot.wiki.site.Site.domain`: the site's web domain, like | - :py:attr:`~earwigbot.wiki.site.Site.domain`: the site's web domain, like | ||||
``"en.wikipedia.org"`` | ``"en.wikipedia.org"`` | ||||
- :py:attr:`~earwigbot.wiki.site.Site.url`: the site's full base URL, like | |||||
``"https://en.wikipedia.org"`` | |||||
and the following methods: | and the following methods: | ||||
@@ -9,18 +9,16 @@ | |||||
def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | ||||
authy = auth(host) | authy = auth(host) | ||||
if command == "access": | if command == "access": | ||||
a = 'The bot\'s owner is "%s".' % OWNER | a = 'The bot\'s owner is "%s".' % OWNER | ||||
b = 'The bot\'s admins are "%s".' % ', '.join(ADMINS_R) | b = 'The bot\'s admins are "%s".' % ', '.join(ADMINS_R) | ||||
reply(a, chan, nick) | reply(a, chan, nick) | ||||
reply(b, chan, nick) | reply(b, chan, nick) | ||||
return | return | ||||
if command == "tock": | |||||
u = urllib.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') | |||||
info = u.info() | |||||
u.close() | |||||
say('"' + info['Date'] + '" - tycho.usno.navy.mil', chan) | |||||
return | |||||
if command == "dict" or command == "dictionary": | if command == "dict" or command == "dictionary": | ||||
def trim(thing): | def trim(thing): | ||||
if thing.endswith(' '): | if thing.endswith(' '): | ||||
@@ -58,6 +56,8 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | |||||
reply('Sorry, no definition found.', chan, nick) | reply('Sorry, no definition found.', chan, nick) | ||||
else: say(result, chan) | else: say(result, chan) | ||||
return | return | ||||
if command == "ety" or command == "etymology": | if command == "ety" or command == "etymology": | ||||
etyuri = 'http://etymonline.com/?term=%s' | etyuri = 'http://etymonline.com/?term=%s' | ||||
etysearch = 'http://etymonline.com/?search=%s' | etysearch = 'http://etymonline.com/?search=%s' | ||||
@@ -126,6 +126,8 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | |||||
msg = 'Can\'t find the etymology for "%s". Try %s' % (word, uri) | msg = 'Can\'t find the etymology for "%s". Try %s' % (word, uri) | ||||
reply(msg, chan, nick) | reply(msg, chan, nick) | ||||
return | return | ||||
if command == "sub" or command == "submissions": | if command == "sub" or command == "submissions": | ||||
try: | try: | ||||
number = int(line2[4]) | number = int(line2[4]) | ||||
@@ -162,6 +164,8 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | |||||
report = "\x02First %s pending AfC submissions:\x0F %s" % (number, s) | report = "\x02First %s pending AfC submissions:\x0F %s" % (number, s) | ||||
say(report, chan) | say(report, chan) | ||||
return | return | ||||
if command == "trout": | if command == "trout": | ||||
try: | try: | ||||
user = line2[4] | user = line2[4] | ||||
@@ -182,6 +186,8 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | |||||
else: | else: | ||||
reply("I refuse to hurt anything with \"Earwig\" in its name :P", chan, nick) | reply("I refuse to hurt anything with \"Earwig\" in its name :P", chan, nick) | ||||
return | return | ||||
if command == "notes" or command == "note" or command == "about" or command == "data" or command == "database": | if command == "notes" or command == "note" or command == "about" or command == "data" or command == "database": | ||||
try: | try: | ||||
action = line2[4] | action = line2[4] | ||||
@@ -55,5 +55,6 @@ class AFCSubmissions(Command): | |||||
site = self.bot.wiki.get_site() | site = self.bot.wiki.get_site() | ||||
category = site.get_category("Pending AfC submissions") | category = site.get_category("Pending AfC submissions") | ||||
pages = ", ".join(category.get_members(use_sql=True, limit=number)) | |||||
members = category.get_members(use_sql=True, limit=number) | |||||
pages = ", ".join([member.url for member in members]) | |||||
self.reply(data, "{0} pending AfC subs: {1}".format(number, pages)) | self.reply(data, "{0} pending AfC subs: {1}".format(number, pages)) |
@@ -498,7 +498,7 @@ class Page(CopyrightMixin): | |||||
else: | else: | ||||
slug = quote(self._title.replace(" ", "_"), safe="/:") | slug = quote(self._title.replace(" ", "_"), safe="/:") | ||||
path = self._site._article_path.replace("$1", slug) | path = self._site._article_path.replace("$1", slug) | ||||
return ''.join((self._site._base_url, path)) | |||||
return ''.join((self._site.url, path)) | |||||
@property | @property | ||||
def namespace(self): | def namespace(self): | ||||
@@ -69,6 +69,7 @@ class Site(object): | |||||
- :py:attr:`project`: the site's project name, like ``"wikipedia"`` | - :py:attr:`project`: the site's project name, like ``"wikipedia"`` | ||||
- :py:attr:`lang`: the site's language code, like ``"en"`` | - :py:attr:`lang`: the site's language code, like ``"en"`` | ||||
- :py:attr:`domain`: the site's web domain, like ``"en.wikipedia.org"`` | - :py:attr:`domain`: the site's web domain, like ``"en.wikipedia.org"`` | ||||
- :py:attr:`url`: the site's URL, like ``"https://en.wikipedia.org"`` | |||||
*Public methods:* | *Public methods:* | ||||
@@ -243,14 +244,7 @@ class Site(object): | |||||
e = "Tried to do an API query, but no API URL is known." | e = "Tried to do an API query, but no API URL is known." | ||||
raise exceptions.SiteAPIError(e) | raise exceptions.SiteAPIError(e) | ||||
base_url = self._base_url | |||||
if base_url.startswith("//"): # Protocol-relative URLs from 1.18 | |||||
if self._use_https: | |||||
base_url = "https:" + base_url | |||||
else: | |||||
base_url = "http:" + base_url | |||||
url = ''.join((base_url, self._script_path, "/api.php")) | |||||
url = ''.join((self.url, self._script_path, "/api.php")) | |||||
params["format"] = "json" # This is the only format we understand | params["format"] = "json" # This is the only format we understand | ||||
if self._assert_edit: # If requested, ensure that we're logged in | if self._assert_edit: # If requested, ensure that we're logged in | ||||
params["assert"] = self._assert_edit | params["assert"] = self._assert_edit | ||||
@@ -548,6 +542,17 @@ class Site(object): | |||||
"""The Site's web domain, like ``"en.wikipedia.org"``.""" | """The Site's web domain, like ``"en.wikipedia.org"``.""" | ||||
return urlparse(self._base_url).netloc | return urlparse(self._base_url).netloc | ||||
@property | |||||
def url(self): | |||||
"""The Site's full base URL, like ``"https://en.wikipedia.org"``.""" | |||||
url = self._base_url | |||||
if url.startswith("//"): # Protocol-relative URLs from 1.18 | |||||
if self._use_https: | |||||
url = "https:" + url | |||||
else: | |||||
url = "http:" + url | |||||
return url | |||||
def api_query(self, **kwargs): | def api_query(self, **kwargs): | ||||
"""Do an API query with `kwargs` as the parameters. | """Do an API query with `kwargs` as the parameters. | ||||