Skip to content

Commit

Permalink
Merge changes from 6.6.5 to main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Mar 24, 2019
2 parents 3ac3e65 + 6e6f710 commit 5197450
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
17 changes: 17 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ This file is used to auto-generate the "Changelog" section of Sopel's website.
When adding new entries, follow the style guide in NEWS.spec.md to avoid causing
problems with the site build.

Changes between 6.6.4 and 6.6.5
===============================

Module changes
--------------

* Fixed url module not cleaning punctuation when auto-titling [[#1515][]]
* Fixed url module's punctuation-cleaning on Python 2 [[#1517][]]
* Fixed `.redditor` command with newer `praw` versions (4.0+) [[#1506][]]
* Reloading modules now runs their `shutdown()` routines [[#1412][]]

[#1412]: https://github.com/sopel-irc/sopel/pull/1412
[#1506]: https://github.com/sopel-irc/sopel/pull/1506
[#1515]: https://github.com/sopel-irc/sopel/pull/1515
[#1517]: https://github.com/sopel-irc/sopel/pull/1517


Changes between 6.6.3 and 6.6.4
===============================

Expand Down
2 changes: 1 addition & 1 deletion sopel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from collections import namedtuple
import re

__version__ = '6.6.4'
__version__ = '6.6.5'


def _version_info(version=__version__):
Expand Down
2 changes: 2 additions & 0 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ def _shutdown(self):
shutdown_method.__module__, e
)
)
# Avoid calling shutdown methods if we already have.
self.shutdown_methods = []

def cap_req(self, module_name, capability, arg=None, failure_callback=None,
success_callback=None):
Expand Down
4 changes: 3 additions & 1 deletion sopel/modules/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def redditor_info(bot, trigger, match=None):
client_secret=None,
)
match = match or trigger
try:
try: # praw <4.0 style
u = r.get_redditor(match.group(2))
except AttributeError: # praw >=4.0 style
u = r.redditor(match.group(2))
except Exception: # TODO: Be specific
if commanded:
bot.say('No such Redditor.')
Expand Down
18 changes: 17 additions & 1 deletion sopel/modules/reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import collections
import sys
import time
from sopel.tools import iteritems
from sopel.tools import stderr, iteritems
import sopel.loader
import sopel.module
import subprocess
Expand Down Expand Up @@ -65,6 +65,22 @@ def reload_module_tree(bot, name, seen=None, silent=False):
old_callables = {}
for obj_name, obj in iteritems(vars(old_module)):
if callable(obj):
if (getattr(obj, '__name__', None) == 'shutdown' and
obj in bot.shutdown_methods):
# If this is a shutdown method, call it first.
try:
stderr(
"calling %s.%s" % (
obj.__module__, obj.__name__,
)
)
obj(bot)
except Exception as e:
stderr(
"Error calling shutdown method for module %s:%s" % (
obj.__module__, e
)
)
bot.unregister(obj)
elif (type(obj) is ModuleType and
obj.__name__.startswith(name + '.') and
Expand Down
4 changes: 2 additions & 2 deletions sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def trim_url(url):

# clean unmatched parentheses/braces/brackets
for (opener, closer) in [('(', ')'), ('[', ']'), ('{', '}'), ('<', '>')]:
if url[-1] is closer and url.count(opener) < url.count(closer):
if (url[-1] == closer) and (url.count(opener) < url.count(closer)):
url = url[:-1]

return url
Expand Down Expand Up @@ -167,7 +167,7 @@ def title_auto(bot, trigger):
if bot.memory['safety_cache'][trigger]['positives'] > 1:
return

urls = find_urls(trigger)
urls = find_urls(trigger, clean=True)
if len(urls) == 0:
return

Expand Down

0 comments on commit 5197450

Please sign in to comment.