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
# this recursively seems easier to me than iteratively
if excess:
self.say(recipient, excess, max_messages - 1)
self.say(excess, recipient, max_messages - 1)
def notice(self, text, dest):
"""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 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
"""
# 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
@ -25,10 +23,6 @@ from tools import get_input
import loader
import os
import sys
if sys.version_info.major < 3:
import ConfigParser
else:
basestring = str
import configparser as ConfigParser
import config.core_section
from config.types import StaticSection
@ -148,7 +142,7 @@ class Config(object):
value = getattr(self, name)
if not value:
return []
if isinstance(value, basestring):
if isinstance(value, str):
value = value.split(',')
# Keep the split value, so we don't have to keep doing this
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))
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:
LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(signature), trigger.raw))
except Exception as e:
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:
LOGGER.error('Exception from {}: {} ({})'.format(trigger.sender, str(e), trigger.raw))

View File

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

View File

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

View File

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

View File

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

View File

@ -70,9 +70,9 @@ def setup(bot):
for oldtime in oldtimes:
for (channel, nick, message) in bot.rdb[oldtime]:
if message:
bot.say(nick + ': ' + message)
bot.say(nick + ': ' + message, channel)
else:
bot.say(nick + '!')
bot.say(nick + '!', channel)
del bot.rdb[oldtime]
dump_database(bot.rfn, bot.rdb)
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
"""Useful miscellaneous tools and shortcuts for Sopel modules
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Useful miscellaneous tools and shortcuts for Sopel modules
*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 os
import re
@ -24,16 +15,9 @@ from collections import defaultdict
from tools._events import events # NOQA
if sys.version_info.major >= 3:
raw_input = input
unicode = str
iteritems = dict.items
itervalues = dict.values
iterkeys = dict.keys
else:
iteritems = dict.iteritems
itervalues = dict.itervalues
iterkeys = dict.iterkeys
_channel_prefixes = ('#', '&', '+', '!')
@ -41,10 +25,7 @@ _channel_prefixes = ('#', '&', '+', '!')
def get_input(prompt):
"""Get decoded input from the terminal (equivalent to python 3's ``input``).
"""
if sys.version_info.major >= 3:
return input(prompt)
else:
return raw_input(prompt).decode('utf8')
def get_raising_file_and_line(tb=None):
@ -122,12 +103,12 @@ class Ddict(dict):
return dict.__getitem__(self, key)
class Identifier(unicode):
"""A `unicode` subclass which acts appropriately for IRC identifiers.
class Identifier(str):
"""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
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
``[]``, ``{}``, ``|``, ``\\``, ``^`` and ``~`` described in RFC 2812.
"""
@ -135,10 +116,10 @@ class Identifier(unicode):
def __new__(cls, identifier):
# 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
# 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
# weird case convention.
s = unicode.__new__(cls, identifier)
s = str.__new__(cls, identifier)
s._lowered = Identifier._lower(identifier)
return s
@ -236,9 +217,9 @@ class OutputRedirect(object):
errors='xmlcharrefreplace') as logfile:
try:
logfile.write(string)
except UnicodeDecodeError:
except strDecodeError:
# 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):
if self.stderr: