Moved the bug command to AdminCommands to reduce abuse.

This commit is contained in:
Jeremy Fincher 2003-10-02 00:26:57 +00:00
parent 4fc4df9ff4
commit 3d0bc9f8b2
3 changed files with 33 additions and 34 deletions

View File

@ -34,7 +34,11 @@ These are commands useful for administrating the bot; they all require their
caller to have the 'admin' capability. This plugin is loaded by default. caller to have the 'admin' capability. This plugin is loaded by default.
""" """
from fix import *
import pprint
import string import string
import smtplib
import conf import conf
import ircdb import ircdb
@ -185,6 +189,35 @@ class AdminCommands(privmsgs.CapabilityCheckingPrivmsg):
conf.prefixChars = s conf.prefixChars = s
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
def bug(self, irc, msg, args):
"""<description>
Reports a bug to a private mailing list supybot-bugs. <description>
will be the subject of the email. The most recent 10 or so messages
the bot receives will be sent in the body of the email.
"""
description = privmsgs.getArgs(args)
messages = pprint.pformat(irc.state.history[-10:])
email = textwrap.dedent("""
Subject: %s
From: jemfinch@users.sourceforge.net
To: supybot-bugs@lists.sourceforge.net
Date: %s
Bug report for Supybot %s.
%s
""") % (description, time.ctime(), conf.version, messages)
email = email.strip()
email = email.replace('\n', '\r\n')
#debug.printf(`email`)
smtp = smtplib.SMTP('mail.sourceforge.net', 25)
smtp.sendmail('jemfinch@users.sf.net',
['supybot-bugs@lists.sourceforge.net'],
email)
smtp.quit()
irc.reply(msg, conf.replySuccess)
bug = privmsgs.thread(bug)
Class = AdminCommands Class = AdminCommands

View File

@ -39,8 +39,6 @@ import os
import sys import sys
import time import time
import getopt import getopt
import pprint
import smtplib
import textwrap import textwrap
from itertools import ifilter from itertools import ifilter
@ -195,35 +193,6 @@ class MiscCommands(callbacks.Privmsg):
else: else:
irc.error(msg, 'There is no such command %s.' % command) irc.error(msg, 'There is no such command %s.' % command)
def bug(self, irc, msg, args):
"""<description>
Reports a bug to a private mailing list supybot-bugs. <description>
will be the subject of the email. The most recent 10 or so messages
the bot receives will be sent in the body of the email.
"""
description = privmsgs.getArgs(args)
messages = pprint.pformat(irc.state.history[-10:])
email = textwrap.dedent("""
Subject: %s
From: jemfinch@users.sourceforge.net
To: supybot-bugs@lists.sourceforge.net
Date: %s
Bug report for Supybot %s.
%s
""") % (description, time.ctime(), conf.version, messages)
email = email.strip()
email = email.replace('\n', '\r\n')
debug.printf(`email`)
smtp = smtplib.SMTP('mail.sourceforge.net', 25)
smtp.sendmail('jemfinch@users.sf.net',
['supybot-bugs@lists.sourceforge.net'],
email)
smtp.quit()
irc.reply(msg, conf.replySuccess)
bug = privmsgs.thread(bug)
def hostmask(self, irc, msg, args): def hostmask(self, irc, msg, args):
"""<nick> """<nick>

View File

@ -83,9 +83,6 @@ class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertNotRegexp('list', name) self.assertNotRegexp('list', name)
self.assertRegexp('list --private', name) self.assertRegexp('list --private', name)
def testBug(self):
self.assertNotError('bug')
def testVersion(self): def testVersion(self):
self.assertNotError('version') self.assertNotError('version')