i need a rundown, stat

This commit is contained in:
iou1name 2018-01-18 23:43:27 -05:00
parent e6e8d544d2
commit 5b1909cac5
10 changed files with 446 additions and 452 deletions

2
bot.py
View File

@ -311,7 +311,7 @@ class Sopel(irc.Bot):
# Now that we've sent the first part, we need to send the rest. Doing # Now that we've sent the first part, we need to send the rest. Doing
# this recursively seems easier to me than iteratively # this recursively seems easier to me than iteratively
if excess: if excess:
self.say(recipient, excess, max_messages - 1) self.say(excess, recipient, max_messages - 1)
def notice(self, text, dest): def notice(self, text, dest):
"""Send an IRC NOTICE to a user or a channel. """Send an IRC NOTICE to a user or a channel.

View File

@ -1,4 +1,5 @@
# coding=utf-8 #! /usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
The config object provides a simplified to access Sopel's configuration file. The config object provides a simplified to access Sopel's configuration file.
The sections of the file are attributes of the object, and the keys in the The sections of the file are attributes of the object, and the keys in the
@ -13,9 +14,6 @@ object is initialized.
.. versionadded:: 6.0.0 .. versionadded:: 6.0.0
""" """
# Copyright 2012-2015, Elsie Powell, embolalia.com
# Copyright © 2012, Elad Alfassa <elad@fedoraproject.org>
# Licensed under the Eiffel Forum License 2.
from __future__ import unicode_literals, absolute_import, print_function, division from __future__ import unicode_literals, absolute_import, print_function, division
@ -25,11 +23,7 @@ from tools import get_input
import loader import loader
import os import os
import sys import sys
if sys.version_info.major < 3: import configparser as ConfigParser
import ConfigParser
else:
basestring = str
import configparser as ConfigParser
import config.core_section import config.core_section
from config.types import StaticSection from config.types import StaticSection
@ -148,7 +142,7 @@ class Config(object):
value = getattr(self, name) value = getattr(self, name)
if not value: if not value:
return [] return []
if isinstance(value, basestring): if isinstance(value, str):
value = value.split(',') value = value.split(',')
# Keep the split value, so we don't have to keep doing this # Keep the split value, so we don't have to keep doing this
setattr(self, name, value) setattr(self, name, value)

4
irc.py
View File

@ -332,12 +332,12 @@ class Bot(asynchat.async_chat):
LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e)) LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e))
if trigger and self.config.core.reply_errors and trigger.sender is not None: if trigger and self.config.core.reply_errors and trigger.sender is not None:
self.msg(trigger.sender, signature) self.say(signature, trigger.sender)
if trigger: if trigger:
LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(signature), trigger.raw)) LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(signature), trigger.raw))
except Exception as e: except Exception as e:
if trigger and self.config.core.reply_errors and trigger.sender is not None: if trigger and self.config.core.reply_errors and trigger.sender is not None:
self.msg(trigger.sender, "Got an error.") self.say("Got an error.", trigger.sender)
if trigger: if trigger:
LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(e), trigger.raw)) LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(e), trigger.raw))

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
Methods for loading modules. Methods for loading modules.
""" """

View File

@ -1,4 +1,3 @@
# coding=utf-8
"""This contains decorators and tools for creating callable plugin functions. """This contains decorators and tools for creating callable plugin functions.
""" """
# Copyright 2013, Ari Koivula, <ari@koivu.la> # Copyright 2013, Ari Koivula, <ari@koivu.la>

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
ASCII ASCII
""" """

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
help.py - Sopel Help Module help.py - Sopel Help Module
Copyright 2008, Sean B. Palmer, inamidst.com Copyright 2008, Sean B. Palmer, inamidst.com

View File

@ -70,9 +70,9 @@ def setup(bot):
for oldtime in oldtimes: for oldtime in oldtimes:
for (channel, nick, message) in bot.rdb[oldtime]: for (channel, nick, message) in bot.rdb[oldtime]:
if message: if message:
bot.say(nick + ': ' + message) bot.say(nick + ': ' + message, channel)
else: else:
bot.say(nick + '!') bot.say(nick + '!', channel)
del bot.rdb[oldtime] del bot.rdb[oldtime]
dump_database(bot.rfn, bot.rdb) dump_database(bot.rfn, bot.rdb)
time.sleep(2.5) time.sleep(2.5)

23
modules/rundown.py Executable file
View File

@ -0,0 +1,23 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Redpill on the Bogdanovs.
"""
import os
import random
from module import commands, example
@commands("rundown")
@example(".rundown")
def grog(bot, trigger):
"""
Provides rundown on demand.
"""
if trigger.group(2) in ["-c", "--cabal"]:
with open(os.path.join(bot.config.homedir, "cabaldown.txt"), "r") as file:
data = file.read()
else:
with open(os.path.join(bot.config.homedir, "rundown.txt"), "r") as file:
data = file.read()
bot.say(data)

View File

@ -1,19 +1,10 @@
# coding=utf-8 #! /usr/bin/env python3
"""Useful miscellaneous tools and shortcuts for Sopel modules # -*- coding: utf-8 -*-
"""
Useful miscellaneous tools and shortcuts for Sopel modules
*Availability: 3+* *Availability: 3+*
""" """
# tools.py - Sopel misc tools
# Copyright 2008, Sean B. Palmer, inamidst.com
# Copyright © 2012, Elad Alfassa <elad@fedoraproject.org>
# Copyright 2012, Elsie Powell, embolalia.com
# Licensed under the Eiffel Forum License 2.
# https://sopel.chat
from __future__ import unicode_literals, absolute_import, print_function, division
import sys import sys
import os import os
import re import re
@ -24,16 +15,9 @@ from collections import defaultdict
from tools._events import events # NOQA from tools._events import events # NOQA
if sys.version_info.major >= 3: iteritems = dict.items
raw_input = input itervalues = dict.values
unicode = str iterkeys = dict.keys
iteritems = dict.items
itervalues = dict.values
iterkeys = dict.keys
else:
iteritems = dict.iteritems
itervalues = dict.itervalues
iterkeys = dict.iterkeys
_channel_prefixes = ('#', '&', '+', '!') _channel_prefixes = ('#', '&', '+', '!')
@ -41,10 +25,7 @@ _channel_prefixes = ('#', '&', '+', '!')
def get_input(prompt): def get_input(prompt):
"""Get decoded input from the terminal (equivalent to python 3's ``input``). """Get decoded input from the terminal (equivalent to python 3's ``input``).
""" """
if sys.version_info.major >= 3:
return input(prompt) return input(prompt)
else:
return raw_input(prompt).decode('utf8')
def get_raising_file_and_line(tb=None): def get_raising_file_and_line(tb=None):
@ -122,12 +103,12 @@ class Ddict(dict):
return dict.__getitem__(self, key) return dict.__getitem__(self, key)
class Identifier(unicode): class Identifier(str):
"""A `unicode` subclass which acts appropriately for IRC identifiers. """A `str` subclass which acts appropriately for IRC identifiers.
When used as normal `unicode` objects, case will be preserved. When used as normal `str` objects, case will be preserved.
However, when comparing two Identifier objects, or comparing a Identifier However, when comparing two Identifier objects, or comparing a Identifier
object with a `unicode` object, the comparison will be case insensitive. object with a `str` object, the comparison will be case insensitive.
This case insensitivity includes the case convention conventions regarding This case insensitivity includes the case convention conventions regarding
``[]``, ``{}``, ``|``, ``\\``, ``^`` and ``~`` described in RFC 2812. ``[]``, ``{}``, ``|``, ``\\``, ``^`` and ``~`` described in RFC 2812.
""" """
@ -135,10 +116,10 @@ class Identifier(unicode):
def __new__(cls, identifier): def __new__(cls, identifier):
# According to RFC2812, identifiers have to be in the ASCII range. # According to RFC2812, identifiers have to be in the ASCII range.
# However, I think it's best to let the IRCd determine that, and we'll # However, I think it's best to let the IRCd determine that, and we'll
# just assume unicode. It won't hurt anything, and is more internally # just assume str. It won't hurt anything, and is more internally
# consistent. And who knows, maybe there's another use case for this # consistent. And who knows, maybe there's another use case for this
# weird case convention. # weird case convention.
s = unicode.__new__(cls, identifier) s = str.__new__(cls, identifier)
s._lowered = Identifier._lower(identifier) s._lowered = Identifier._lower(identifier)
return s return s
@ -236,9 +217,9 @@ class OutputRedirect(object):
errors='xmlcharrefreplace') as logfile: errors='xmlcharrefreplace') as logfile:
try: try:
logfile.write(string) logfile.write(string)
except UnicodeDecodeError: except strDecodeError:
# we got an invalid string, safely encode it to utf-8 # we got an invalid string, safely encode it to utf-8
logfile.write(unicode(string, 'utf8', errors="replace")) logfile.write(str(string, 'utf8', errors="replace"))
def flush(self): def flush(self):
if self.stderr: if self.stderr: