Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot, ip: fix minor type issues #2393

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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