Add DEV_CHANNEL and send tracebacks there instead

Per @skizzerz, tracebacks can reveal potentially sensitive game info.
Therefore, I added an option to send the tracebacks to an alternate
channel instead. You can even send them only to voiced or opped users.
This commit is contained in:
nyuszika7h 2015-02-28 11:56:56 +01:00
parent 0ebb4d5e36
commit 1cc6d411f8
2 changed files with 10 additions and 7 deletions

View File

@ -33,5 +33,8 @@ USE_UTC = True # if True, will use the UTC time, else the local time
# %Y is the year with century, %y is the year without, %m is the month, %d the day, %H hour, %M minute and %S seconds # %Y is the year with century, %y is the year without, %m is the month, %d the day, %H hour, %M minute and %S seconds
TIMESTAMP_FORMAT = "[%Y-%m-%d %H:%M:%S{tzoffset}]" TIMESTAMP_FORMAT = "[%Y-%m-%d %H:%M:%S{tzoffset}]"
# If enabled, when an exception is caught, the bot will post it to termbin.com and post the link to the channel. # If enabled and DEV_CHANNEL is set, the bot will post tracebacks there.
PASTEBIN_ERRORS = True PASTEBIN_ERRORS = False
# Channel(s) where errors will be sent to. Can be prefixed with '+' or '@' for sending to only voices or ops.
DEV_CHANNEL = ""

View File

@ -21,7 +21,9 @@ def notify_error(cli, chan, target_logger):
target_logger(tb) target_logger(tb)
if botconfig.PASTEBIN_ERRORS: cli.msg(chan, msg)
if botconfig.PASTEBIN_ERRORS and botconfig.DEV_CHANNEL:
try: try:
with socket.socket() as sock: with socket.socket() as sock:
sock.connect(("termbin.com", 9999)) sock.connect(("termbin.com", 9999))
@ -30,10 +32,7 @@ def notify_error(cli, chan, target_logger):
except socket.error: except socket.error:
target_logger(traceback.format_exc()) target_logger(traceback.format_exc())
else: else:
msg += " " cli.msg(botconfig.DEV_CHANNEL, " ".join((msg, url)))
msg += url
cli.msg(chan, msg)
def on_privmsg(cli, rawnick, chan, msg, notice = False): def on_privmsg(cli, rawnick, chan, msg, notice = False):
@ -110,6 +109,7 @@ def connect_callback(cli):
def prepare_stuff(*args): def prepare_stuff(*args):
cli.join(botconfig.CHANNEL) cli.join(botconfig.CHANNEL)
cli.join(botconfig.ALT_CHANNELS) cli.join(botconfig.ALT_CHANNELS)
cli.join(",".join(chan.lstrip("@+") for chan in botconfig.DEV_CHANNEL.split(",")))
cli.msg("ChanServ", "op "+botconfig.CHANNEL) cli.msg("ChanServ", "op "+botconfig.CHANNEL)
cli.cap("REQ", "extended-join") cli.cap("REQ", "extended-join")