Skip to content

Commit

Permalink
Merge 6.6.x into master after release of v6.6.6
Browse files Browse the repository at this point in the history
Hopefully this is one of the last merges like this, before we let the
6.6.x release series rest and focus 100% on Sopel 7.
  • Loading branch information
dgw committed Apr 15, 2019
2 parents 985d3bb + 25e6469 commit c13257d
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 21 deletions.
61 changes: 61 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,67 @@ 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.5 and 6.6.6
===============================

This slightly cursed version of Sopel is brought to you by the following happy
coincidences. When this release cycle began:

* 6.6.6 was the next patch version number
* Tax Day (in the U.S.) was just a few weeks off — the perfect release date

As it happens, the [v6.6.6 GitHub milestone][ms-666] ended up with 13 closed
issues/PRs in total. We *definitely* didn't try to *plan* any of this. Promise.

[ms-666]: https://github.com/sopel-irc/sopel/milestone/21?closed=1

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

* Potential denial-of-service via repeated long output in the `.py` and `.calc`
commands was mitigated [[#1552][]]
* `admin` module's `.set` command no longer throws an exception if missing
arguments [[#1520][]]
* Fixed `admin` module's `.mode` command sending invalid raw line [[#1549][]]
* Tweaked output-formatting code in the `meetbot` & `reddit` modules [[#1516][]]
* The most visible effect of this is that moderators' names will now appear
green in `reddit`'s output, like on the site, instead of the old brown/purple
* Updated example/test output for `.ip` command [[#1523][]]

Core changes
------------

* Flood protection delay is now capped at 2 seconds [[#1552][]]
* The flood delay penalty is calculated using the message length before
truncation. Very long command output could thus "hang" the bot for many
minutes at a time, meaning some modules could be used to DoS the bot.
* Sopel 7 will add configuration for flood protection and perhaps reorganize
the logic to reduce silly bugs like this. (See: [#1518][], [#1559][])
* Fixed a few cases where keyboard interrupt (Control + C) wasn't handled
correctly [[#1534][], [#1558][]]
* Fixed invalid `MODE` command sent during connection phase [[#1544][]]

API changes
-----------

* Fixed a regression in testing modules by running them directly [[#1529][]]
* Fixed that `bot` output methods (`say`, `reply`, etc.) would cause errors
during tests if passed certain keyword arguments [[#1538][]]

[#1516]: https://github.com/sopel-irc/sopel/pull/1516
[#1518]: https://github.com/sopel-irc/sopel/pull/1518
[#1520]: https://github.com/sopel-irc/sopel/pull/1520
[#1523]: https://github.com/sopel-irc/sopel/pull/1523
[#1529]: https://github.com/sopel-irc/sopel/pull/1529
[#1534]: https://github.com/sopel-irc/sopel/pull/1534
[#1538]: https://github.com/sopel-irc/sopel/pull/1538
[#1544]: https://github.com/sopel-irc/sopel/pull/1544
[#1549]: https://github.com/sopel-irc/sopel/pull/1549
[#1552]: https://github.com/sopel-irc/sopel/pull/1552
[#1558]: https://github.com/sopel-irc/sopel/pull/1558
[#1559]: https://github.com/sopel-irc/sopel/issues/1559


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

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.5'
__version__ = '6.6.6'


def _version_info(version=__version__):
Expand Down
2 changes: 1 addition & 1 deletion sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def say(self, text, recipient, max_messages=1):
elapsed = time.time() - self.stack[recipient_id][-1][0]
if elapsed < 3:
penalty = float(max(0, len(text) - 40)) / 70
wait = 0.8 + penalty
wait = min(0.8 + penalty, 2) # Never wait more than 2 seconds
if elapsed < wait:
time.sleep(wait - elapsed)

Expand Down
2 changes: 1 addition & 1 deletion sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def startup(bot, trigger):
auth_after_register(bot)

modes = bot.config.core.modes
bot.write(('MODE ', '%s +%s' % (bot.nick, modes)))
bot.write(('MODE', '%s +%s' % (bot.nick, modes)))

bot.memory['retry_join'] = dict()

Expand Down
6 changes: 4 additions & 2 deletions sopel/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def restart(self, message):

def quit(self, message):
"""Disconnect from IRC and close the bot."""
self.write(['QUIT'], message)
if self.connected: # Only send QUIT message if socket is open
self.write(['QUIT'], message)
self.hasquit = True
# Wait for acknowledgement from the server. By RFC 2812 it should be
# an ERROR msg, but many servers just close the connection. Either way
Expand All @@ -234,7 +235,8 @@ def handle_close(self):
# This will eventually call asyncore dispatchers close method, which
# will release the main thread. This should be called last to avoid
# race conditions.
self.close()
if self.socket:
self.close()

def handle_connect(self):
"""
Expand Down
8 changes: 6 additions & 2 deletions sopel/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def hold_ground(bot, trigger):
def mode(bot, trigger):
"""Set a user mode on Sopel. Can only be done in privmsg by an admin."""
mode = trigger.group(3)
bot.write(('MODE ', bot.nick + ' ' + mode))
bot.write(('MODE', bot.nick + ' ' + mode))


@sopel.module.require_privmsg("This command only works as a private message.")
Expand All @@ -262,7 +262,11 @@ def set_config(bot, trigger):
If value is None, the option will be deleted.
"""
# Get section and option from first argument.
arg1 = trigger.group(3).split('.')
match = trigger.group(3)
if match is None:
bot.reply("Usage: .set section.option value")
return
arg1 = match.split('.')
if len(arg1) == 1:
section_name, option = "core", arg1[0]
elif len(arg1) == 2:
Expand Down
1 change: 1 addition & 0 deletions sopel/modules/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import unicode_literals, absolute_import, print_function, division

import sopel
import sopel.module
import sys
if sys.version_info.major >= 3:
# Backup stderr/stdout wrappers
Expand Down
21 changes: 12 additions & 9 deletions sopel/modules/meetbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from sopel.config.types import (
StaticSection, FilenameAttribute, ValidatedAttribute
)
from sopel.formatting import bold
from sopel.web import quote
from sopel.modules.url import find_title
from sopel.module import example, commands, rule, priority
Expand Down Expand Up @@ -193,7 +194,9 @@ def startmeeting(bot, trigger):
logplain('Meeting started by ' + trigger.nick.lower(), trigger.sender)
logHTML_start(trigger.sender)
meeting_actions[trigger.sender] = []
bot.say('Meeting started! use .action, .agreed, .info, .chairs, .subject and .comments to control the meeting. to end the meeting, type .endmeeting')
bot.say(bold('Meeting started!') + ' use .action, .agreed, .info, '
'.chairs, .subject and .comments to control the meeting. to end '
'the meeting, type .endmeeting')
bot.say('Users without speaking permission can use .comment ' +
trigger.sender + ' followed by their comment in a PM with me to '
'vocalize themselves.')
Expand Down Expand Up @@ -221,7 +224,7 @@ def meetingsubject(bot, trigger):
logfile.write('</ul><h3>' + trigger.group(2) + '</h3><ul>')
logfile.close()
logplain('Current subject: ' + trigger.group(2) + ', (set by ' + trigger.nick + ')', trigger.sender)
bot.say('Current subject: ' + trigger.group(2))
bot.say(bold('Current subject:') + ' ' + trigger.group(2))


# End the meeting
Expand All @@ -240,7 +243,7 @@ def endmeeting(bot, trigger):
return
meeting_length = time.time() - meetings_dict[trigger.sender]['start']
# TODO: Humanize time output
bot.say("Meeting ended! total meeting length %d seconds" % meeting_length)
bot.say(bold("Meeting ended!") + " total meeting length %d seconds" % meeting_length)
logHTML_end(trigger.sender)
htmllog_url = meeting_log_baseurl + quote(trigger.sender + '/' + figure_logfile_name(trigger.sender) + '.html')
logplain('Meeting ended by %s, total meeting length %d seconds' % (trigger.nick, meeting_length), trigger.sender)
Expand Down Expand Up @@ -268,7 +271,7 @@ def chairs(bot, trigger):
chairs_readable = trigger.group(2).lower().replace(' ', ', ')
logplain('Meeting chairs are: ' + chairs_readable, trigger.sender)
logHTML_listitem('<span style="font-weight: bold">Meeting chairs are: </span>' + chairs_readable, trigger.sender)
bot.say('Meeting chairs are: ' + chairs_readable)
bot.say(bold('Meeting chairs are:') + ' ' + chairs_readable)
else:
bot.say("Only meeting head can set chairs")

Expand All @@ -293,7 +296,7 @@ def meetingaction(bot, trigger):
logplain('ACTION: ' + trigger.group(2), trigger.sender)
logHTML_listitem('<span style="font-weight: bold">Action: </span>' + trigger.group(2), trigger.sender)
meeting_actions[trigger.sender].append(trigger.group(2))
bot.say('ACTION: ' + trigger.group(2))
bot.say(bold('ACTION:') + ' ' + trigger.group(2))


@commands('listactions')
Expand All @@ -303,7 +306,7 @@ def listactions(bot, trigger):
bot.say('Can\'t do that, start meeting first')
return
for action in meeting_actions[trigger.sender]:
bot.say('ACTION: ' + action)
bot.say(bold('ACTION:') + ' ' + action)


# Log agreed item in the HTML log
Expand All @@ -325,7 +328,7 @@ def meetingagreed(bot, trigger):
return
logplain('AGREED: ' + trigger.group(2), trigger.sender)
logHTML_listitem('<span style="font-weight: bold">Agreed: </span>' + trigger.group(2), trigger.sender)
bot.say('AGREED: ' + trigger.group(2))
bot.say(bold('AGREED:') + ' ' + trigger.group(2))


# Log link item in the HTML log
Expand Down Expand Up @@ -354,7 +357,7 @@ def meetinglink(bot, trigger):
title = ''
logplain('LINK: %s [%s]' % (link, title), trigger.sender)
logHTML_listitem('<a href="%s">%s</a>' % (link, title), trigger.sender)
bot.say('LINK: ' + link)
bot.say(bold('LINK:') + ' ' + link)


# Log informational item in the HTML log
Expand All @@ -376,7 +379,7 @@ def meetinginfo(bot, trigger):
return
logplain('INFO: ' + trigger.group(2), trigger.sender)
logHTML_listitem(trigger.group(2), trigger.sender)
bot.say('INFO: ' + trigger.group(2))
bot.say(bold('INFO:') + ' ' + trigger.group(2))


# called for every single message
Expand Down
10 changes: 5 additions & 5 deletions sopel/modules/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def rpost_info(bot, trigger, match=None):

if s.over_18:
if subreddit.lower() in spoiler_subs:
nsfw = bold(color(' [SPOILERS]', colors.RED))
nsfw = ' ' + bold(color('[SPOILERS]', colors.RED))
else:
nsfw = bold(color(' [NSFW]', colors.RED))
nsfw = ' ' + bold(color('[NSFW]', colors.RED))

sfw = bot.db.get_channel_value(trigger.sender, 'sfw')
if sfw:
Expand Down Expand Up @@ -148,13 +148,13 @@ def redditor_info(bot, trigger, match=None):
is_cakeday = cakeday_start <= now <= cakeday_start + day

if is_cakeday:
message = message + ' | 13Cake day'
message = message + ' | ' + bold(color('Cake day', colors.LIGHT_PURPLE))
if commanded:
message = message + ' | https://reddit.com/u/' + u.name
if u.is_gold:
message = message + ' | 08Gold'
message = message + ' | ' + bold(color('Gold', colors.YELLOW))
if u.is_mod:
message = message + ' | 05Mod'
message = message + ' | ' + bold(color('Mod', colors.GREEN))
message = message + (' | Link: ' + str(u.link_karma) +
' | Comment: ' + str(u.comment_karma))

Expand Down
1 change: 1 addition & 0 deletions sopel/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sopel.config
import sopel.config.core_section
import sopel.tools
import sopel.tools.target
import sopel.trigger


Expand Down

0 comments on commit c13257d

Please sign in to comment.