PEP8 compliance, reduce munging on tagged names

This commit is contained in:
Ryan Hitchman 2010-03-27 02:42:27 -06:00
parent 9a9922a3ca
commit 2a11825779
18 changed files with 2652 additions and 2652 deletions

View File

@ -17,7 +17,7 @@ class Input(dict):
conn.msg(chan, msg)
def reply(msg):
if chan == nick: # PMs don't need prefixes
if chan == nick: # PMs don't need prefixes
conn.msg(chan, msg)
else:
conn.msg(chan, nick + ': ' + msg)
@ -120,10 +120,9 @@ def main(conn, out):
for func, args in bot.events[inp.command] + bot.events['*']:
dispatch(Input(conn, *out), "event", func, args)
if inp.command == 'PRIVMSG':
# COMMANDS
if inp.chan == inp.nick: # private message, no command prefix
if inp.chan == inp.nick: # private message, no command prefix
prefix = r'^(?:[.!]?|'
else:
prefix = r'^(?:[.!]|'

View File

@ -28,11 +28,9 @@ def format_plug(plug, kind='', lpad=0, width=40):
if kind == 'regex':
out += ' ' * (50 - len(out)) + plug[1]['regex']
return out
def reload(init=False):
changed = False
@ -149,7 +147,7 @@ def reload(init=False):
commands[make_signature(func)].append(name)
for sig, names in sorted(commands.iteritems()):
names.sort(key=lambda x: (-len(x), x)) # long names first
names.sort(key=lambda x: (-len(x), x)) # long names first
out = ' ' * 6 + '%s:%s:%s' % sig
out += ' ' * (50 - len(out)) + ', '.join(names)
print out

View File

@ -10,7 +10,7 @@ from util import hook
api_url = "http://encyclopediadramatica.com/api.php?action=opensearch&search="
ed_url = "http://encyclopediadramatica.com/"
ua_header = ('User-Agent','Skybot/1.0 http://bitbucket.org/Scaevolus/skybot/')
ua_header = ('User-Agent', 'Skybot/1.0 http://bitbucket.org/Scaevolus/skybot/')
@hook.command('ed')

View File

@ -11,11 +11,12 @@ from util import hook
# say('(--[. ]-[ .] /')
# say('(_______o__)')
@hook.command
@hook.command('gs')
def goonsay(inp):
".gs/.goonsay <id|add [message]> -- Get's the goonsay.com result for <id> or "
"add a new :goonsay: to the database. If no arg it will get a random result."
".gs/.goonsay <id|add [message]> -- Get's the goonsay.com result for <id> "
" or add a new :goonsay: to the database. With no args, random result."
url = "http://goonsay.com/api/goonsays"
@ -44,7 +45,8 @@ def goonsay(inp):
if len(inp):
try:
req = urllib2.Request('%s/%d/' % (url, int(inp)), None, req_headers)
req = urllib2.Request('%s/%d/' % (url, int(inp)), None,
req_headers)
j = json.loads(urllib2.urlopen(req).read())
except urllib2.HTTPError, e:
if e.code == 410 or e.code == 404:

View File

@ -28,7 +28,6 @@ def mtg(inp):
text = re.sub(r'\(.*?\)', '', text) # strip parenthetical explanations
text = re.sub(r'\.(\S)', r'. \1', text) # fix spacing
printings = card.find('td/small').text_content()
printings = re.search(r'Editions:(.*)Languages:', printings).group(1)
printings = re.findall(r'\s*(.+?(?: \([^)]+\))*) \((.*?)\)',

View File

@ -108,7 +108,7 @@ def tag(inp, chan='', db=None):
if not tags:
return get_nicks_by_tag(db, chan, inp)
else:
return 'tags for "%s": ' % munge(inp, 3) + ', '.join(
return 'tags for "%s": ' % munge(inp, 1) + ', '.join(
tag[0] for tag in tags)

View File

@ -36,7 +36,8 @@ def tellinput(paraml, input=None, db=None, bot=None):
user_from, message, time, chan = tells[0]
reltime = timesince.timesince(time)
reply = "%s said %s ago in %s: %s" % (user_from, reltime, chan, message)
reply = "%s said %s ago in %s: %s" % (user_from, reltime, chan,
message)
if len(tells) > 1:
reply += " (+%d more, .showtells to view)" % (len(tells) - 1)

View File

@ -34,9 +34,10 @@ def _hook_add(func, add, name=''):
args.append(0) # means kwargs present
func._args = args
if not hasattr(func, '_thread'): # does function run in its own thread?
if not hasattr(func, '_thread'): # does function run in its own thread?
func._thread = False
def sieve(func):
if func.func_code.co_argcount != 5:
raise ValueError(