Skip to content

Commit

Permalink
Merge pull request #2393 from Exirel/mypy-type-fix-bot-and-ip
Browse files Browse the repository at this point in the history
bot, ip: fix minor type issues
  • Loading branch information
dgw authored Jan 5, 2023
2 parents bd16d68 + 7f07a95 commit 2bdf7cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def on_job_error(
def error(
self,
trigger: Optional[Trigger] = None,
exception: BaseException = None,
exception: Optional[BaseException] = None,
):
"""Called internally when a plugin causes an error.
Expand Down
43 changes: 21 additions & 22 deletions sopel/modules/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,29 @@ def _find_geoip_db(bot):
elif (os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLite2-City.mmdb')) and
os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLite2-ASN.mmdb'))):
return '/usr/share/GeoIP'
elif urlretrieve:
LOGGER.info('Downloading GeoIP database')
bot.say('Downloading GeoIP database, please wait...')

common_params = {'license_key': 'JXBEmLjOzislFnh4', 'suffix': 'tar.gz'}
base_url = 'https://download.maxmind.com/app/geoip_download'
geolite_urls = []

for edition in ['ASN', 'City']:
geolite_urls.append(
'{base}?{params}'.format(
base=base_url,
params=web.urlencode(dict(common_params, **{'edition_id': 'GeoLite2-%s' % edition})),
)

LOGGER.info('Downloading GeoIP database')
bot.say('Downloading GeoIP database, please wait...')

common_params = {'license_key': 'JXBEmLjOzislFnh4', 'suffix': 'tar.gz'}
base_url = 'https://download.maxmind.com/app/geoip_download'
geolite_urls = []

for edition in ['ASN', 'City']:
geolite_urls.append(
'{base}?{params}'.format(
base=base_url,
params=web.urlencode(dict(common_params, **{'edition_id': 'GeoLite2-%s' % edition})),
)
)

for url in geolite_urls:
LOGGER.debug('GeoIP Source URL: %s', url)
full_path = os.path.join(config.core.homedir, url.split("/")[-1])
urlretrieve(url, full_path)
_decompress(full_path, config.core.homedir)
return bot.config.core.homedir
else:
return False
for url in geolite_urls:
LOGGER.debug('GeoIP Source URL: %s', url)
full_path = os.path.join(config.core.homedir, url.split("/")[-1])
urlretrieve(url, full_path)
_decompress(full_path, config.core.homedir)

return config.core.homedir


@plugin.command('iplookup', 'ip')
Expand Down

0 comments on commit 2bdf7cb

Please sign in to comment.