Skip to content

Commit 5e52ba7

Browse files
committed
200->150
1 parent fcba5d6 commit 5e52ba7

29 files changed

+197
-105
lines changed

.style.yapf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[style]
22
based_on_style = google
3-
column_limit = 200
3+
column_limit = 150

cslbot/commands/about.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ def cmd(send, _, args):
2525
Syntax: {command}
2626
2727
"""
28-
send("See https://github.com/%s Developed by the TJHSST CSL. Type %shelp for a list of commands." % (args['config']['api']['githubrepo'], args['config']['core']['cmdchar']))
28+
send("See https://github.com/%s Developed by the TJHSST CSL. Type %shelp for a list of commands." %
29+
(args['config']['api']['githubrepo'], args['config']['core']['cmdchar']))

cslbot/commands/babble.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def weighted_next(data):
4141
def build_msg(cursor, speaker, length, start):
4242
table = Babble if length == 1 else Babble2
4343
location = 'target' if speaker.startswith(('#', '+', '@')) else 'source'
44-
count = cursor.query(Babble_count.count).filter(Babble_count.type == location, Babble_count.length == length, Babble_count.key == speaker).scalar()
44+
count = cursor.query(Babble_count.count).filter(Babble_count.type == location, Babble_count.length == length,
45+
Babble_count.key == speaker).scalar()
4546
if count is None:
4647
return "%s hasn't said anything =(" % speaker
4748
if start is None:

cslbot/commands/choose.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def cmd(send, msg, args):
3131
send("Choose what?")
3232
return
3333
choices = msg.split(' or ')
34-
action = ['draws a slip of paper from a hat and gets...', 'says eenie, menie, miney, moe and chooses...', 'picks a random number and gets...', 'rolls dice and gets...',
35-
'asks a random person and gets...', 'plays rock, paper, scissors, lizard, spock and gets...']
34+
action = ['draws a slip of paper from a hat and gets...', 'says eenie, menie, miney, moe and chooses...', 'picks a random number and gets...',
35+
'rolls dice and gets...', 'asks a random person and gets...', 'plays rock, paper, scissors, lizard, spock and gets...']
3636
send("%s %s" % (choice(action), choice(choices)), 'action')

cslbot/commands/ebay.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ def get_categories(apikey):
3434

3535
def get_item(category, apikey):
3636
url = 'http://svcs.ebay.com/services/search/FindingService/v1?'
37-
params = [('itemFilter(0).name', 'FreeShippingOnly'), ('itemFilter(0).value', 'true'), ('itemFilter(1).name', 'MaxPrice'), ('itemFilter(1).value', '1'), ('itemFilter(1).paramName', 'Currency'),
38-
('itemFilter(1).paramValue', 'USD'), ('itemFilter(2).name', 'ListingType'), ('itemFilter(2).value(0)', 'StoreInventory'), ('itemFilter(2).value(1)', 'FixedPrice'),
37+
params = [('itemFilter(0).name', 'FreeShippingOnly'), ('itemFilter(0).value', 'true'), ('itemFilter(1).name', 'MaxPrice'),
38+
('itemFilter(1).value', '1'), ('itemFilter(1).paramName', 'Currency'), ('itemFilter(1).paramValue', 'USD'),
39+
('itemFilter(2).name', 'ListingType'), ('itemFilter(2).value(0)', 'StoreInventory'), ('itemFilter(2).value(1)', 'FixedPrice'),
3940
('itemFilter(2).value(2)', 'AuctionWithBIN'), ('categoryId', category)]
4041
# If we use params=, requests will urlencode the (), making ebay very sad.
4142
url += "&".join("%s=%s" % x for x in params)

cslbot/commands/highlight.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def cmd(send, msg, args):
4040
return
4141
target = cmdargs.channels[0] if hasattr(cmdargs, 'channels') else args['target']
4242
row = args['db'].query(Log).filter(
43-
Log.msg.ilike("%%%s%%" % cmdargs.nick), ~Log.msg.contains('%shighlight' % args['config']['core']['cmdchar']), Log.target == target, Log.source != args['botnick'], Log.source != cmdargs.nick,
44-
(Log.type == 'pubmsg') | (Log.type == 'privmsg') | (Log.type == 'action')).order_by(Log.time.desc()).first()
43+
Log.msg.ilike("%%%s%%" % cmdargs.nick), ~Log.msg.contains('%shighlight' % args['config']['core']['cmdchar']), Log.target == target,
44+
Log.source != args['botnick'], Log.source != cmdargs.nick, (Log.type == 'pubmsg') | (Log.type == 'privmsg') |
45+
(Log.type == 'action')).order_by(Log.time.desc()).first()
4546
if row is None:
4647
send("%s has never been pinged." % cmdargs.nick)
4748
else:

cslbot/commands/issue.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def cmd(send, msg, args):
8484
row = Issues(title=cmdargs.title, description=cmdargs.description, source=str(args['source'])) # str needed to make mysqlconnector happy
8585
args['db'].add(row)
8686
args['db'].flush()
87-
send("New Issue: #%d -- %s -- %s, Submitted by %s" % (row.id, cmdargs.title, cmdargs.description, args['nick']), target=args['config']['core']['ctrlchan'])
87+
send("New Issue: #%d -- %s -- %s, Submitted by %s" % (row.id, cmdargs.title, cmdargs.description, args['nick']),
88+
target=args['config']['core']['ctrlchan'])
8889
send("Issue submitted for approval.", target=args['nick'])
8990
else:
9091
send("Invalid arguments.")

cslbot/commands/jargon.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919

2020
from ..helpers.command import Command
2121

22-
abbrev = ["TCP", "HTTP", "SDD", "RAM", "GB", "CSS", "SSL", "AGP", "SQL", "FTP", "PCI", "AI", "ADP", "RSS", "XML", "EXE", "COM", "HDD", "THX", "SMTP", "SMS", "USB", "PNG"]
22+
abbrev = ["TCP", "HTTP", "SDD", "RAM", "GB", "CSS", "SSL", "AGP", "SQL", "FTP", "PCI", "AI", "ADP", "RSS", "XML", "EXE", "COM", "HDD", "THX", "SMTP",
23+
"SMS", "USB", "PNG"]
2324

24-
adj = ["auxiliary", "primary", "back-end", "digital", "open-source", "virtual", "cross-platform", "redundant", "online", "haptic", "multi-byte", "bluetooth", "wireless", "1080p", "neural", "optical",
25-
"solid state", "mobile"]
25+
adj = ["auxiliary", "primary", "back-end", "digital", "open-source", "virtual", "cross-platform", "redundant", "online", "haptic", "multi-byte",
26+
"bluetooth", "wireless", "1080p", "neural", "optical", "solid state", "mobile"]
2627

27-
noun = ["driver", "protocol", "bandwidth", "panel", "microchip", "program", "port", "card", "array", "interface", "system", "sensor", "firewall", "hard drive", "pixel", "alarm", "feed", "monitor",
28-
"application", "transmitter", "bus", "circuit", "capacitor", "matrix"]
28+
noun = ["driver", "protocol", "bandwidth", "panel", "microchip", "program", "port", "card", "array", "interface", "system", "sensor", "firewall",
29+
"hard drive", "pixel", "alarm", "feed", "monitor", "application", "transmitter", "bus", "circuit", "capacitor", "matrix"]
2930

30-
verb = ["back up", "bypass", "hack", "override", "compress", "copy", "navigate", "index", "connect", "generate", "quantify", "calculate", "synthesize", "input", "transmit", "program", "reboot",
31-
"parse"]
31+
verb = ["back up", "bypass", "hack", "override", "compress", "copy", "navigate", "index", "connect", "generate", "quantify", "calculate",
32+
"synthesize", "input", "transmit", "program", "reboot", "parse"]
3233

33-
ingverb = ["backing up", "bypassing", "hacking", "overriding", "compressing", "copying", "navigating", "indexing", "connecting", "generating", "quantifying", "calculating", "synthesizing",
34-
"transmitting", "programming", "parsing"]
34+
ingverb = ["backing up", "bypassing", "hacking", "overriding", "compressing", "copying", "navigating", "indexing", "connecting", "generating",
35+
"quantifying", "calculating", "synthesizing", "transmitting", "programming", "parsing"]
3536

3637

3738
@Command('jargon')
@@ -41,11 +42,14 @@ def cmd(send, *_):
4142
Syntax: {command}
4243
4344
"""
44-
words = [[verb, noun, abbrev, noun, adj, abbrev, noun], [verb, adj, abbrev, noun], [verb, abbrev, noun, verb, adj, noun], [verb, noun, ingverb, adj, abbrev, noun],
45-
[adj, abbrev, noun, verb, adj, noun], [abbrev, noun, verb, adj, noun, verb, abbrev, noun], [ingverb, noun, verb, adj, abbrev, noun], [verb, adj, abbrev, noun, verb, abbrev, noun]]
46-
msgtype = ["If we %s the %s, we can get to the %s %s through the %s %s %s!" % tuple(map(choice, words[0])), "We need to %s the %s %s %s!" % tuple(map(choice, words[1])),
47-
"Try to %s the %s %s, maybe it will %s the %s %s!" % tuple(map(choice, words[2])), "You can't %s the %s without %s the %s %s %s!" % tuple(map(choice, words[3])),
48-
"Use the %s %s %s, then you can %s the %s %s!" % tuple(map(choice, words[4])), "The %s %s is down, %s the %s %s so we can %s the %s %s!" % tuple(map(choice, words[5])),
49-
"%s the %s won't do anything, we need to %s the %s %s %s!" % tuple(map(choice, words[6])), "I'll %s the %s %s %s, that should %s the %s %s!" % tuple(map(choice, words[7]))]
45+
words = [[verb, noun, abbrev, noun, adj, abbrev, noun], [verb, adj, abbrev, noun], [verb, abbrev, noun, verb, adj, noun],
46+
[verb, noun, ingverb, adj, abbrev, noun], [adj, abbrev, noun, verb, adj, noun], [abbrev, noun, verb, adj, noun, verb, abbrev, noun],
47+
[ingverb, noun, verb, adj, abbrev, noun], [verb, adj, abbrev, noun, verb, abbrev, noun]]
48+
msgtype = ["If we %s the %s, we can get to the %s %s through the %s %s %s!" % tuple(map(choice, words[0])), "We need to %s the %s %s %s!" %
49+
tuple(map(choice, words[1])), "Try to %s the %s %s, maybe it will %s the %s %s!" % tuple(map(choice, words[2])),
50+
"You can't %s the %s without %s the %s %s %s!" % tuple(map(choice, words[3])), "Use the %s %s %s, then you can %s the %s %s!" %
51+
tuple(map(choice, words[4])), "The %s %s is down, %s the %s %s so we can %s the %s %s!" % tuple(map(choice, words[5])),
52+
"%s the %s won't do anything, we need to %s the %s %s %s!" % tuple(map(choice, words[6])),
53+
"I'll %s the %s %s %s, that should %s the %s %s!" % tuple(map(choice, words[7]))]
5054

5155
send(choice(msgtype))

cslbot/commands/line.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def cmd(send, msg, args):
4444
else:
4545
quote = quote.filter(Log.source != args['botnick'])
4646
target = cmdargs.channels[0] if hasattr(cmdargs, 'channels') else args['config']['core']['channel']
47-
quote = quote.filter(or_(Log.type == 'pubmsg', Log.type == 'privmsg', Log.type == 'action'), Log.target == target, func.length(Log.msg) > 5).order_by(func.random()).first()
47+
quote = quote.filter(
48+
or_(Log.type == 'pubmsg', Log.type == 'privmsg',
49+
Log.type == 'action'), Log.target == target, func.length(Log.msg) > 5).order_by(func.random()).first()
4850
if quote:
4951
send("%s -- %s" % quote)
5052
elif nick:

cslbot/commands/s.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727

2828
def get_log(conn, target, user):
29-
query = conn.query(Log).filter((Log.type == 'privmsg') | (Log.type == 'pubmsg') | (Log.type == 'action'), Log.target == target).order_by(Log.time.desc())
29+
query = conn.query(Log).filter(
30+
(Log.type == 'privmsg') | (Log.type == 'pubmsg') | (Log.type == 'action'), Log.target == target).order_by(Log.time.desc())
3031
if user is None:
3132
return query.offset(1).limit(500).all()
3233
else:

cslbot/commands/seen.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
def get_last(cursor, cmdchar, ctrlchan, nick):
2525
command = '%sseen %s' % (cmdchar, nick)
26-
return cursor.query(Log).filter(Log.source.ilike(nick), Log.target != ctrlchan, Log.msg != command, Log.type != 'join').order_by(Log.time.desc()).first()
26+
return cursor.query(Log).filter(
27+
Log.source.ilike(nick), Log.target != ctrlchan, Log.msg != command, Log.type != 'join').order_by(Log.time.desc()).first()
2728

2829

2930
@Command('seen', ['db', 'config'])

cslbot/commands/stock.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def gen_stock(msg):
3131
changepercent = "%.3f%%" % quote['ChangePercent']
3232
if quote['ChangePercent'] >= 0:
3333
changepercent = '+' + changepercent
34-
return "%s (%s) as of %s: %s %s High: %s Low: %s" % (quote['Name'], msg, quote['Timestamp'], quote['LastPrice'], changepercent, quote['High'], quote['Low'])
34+
return "%s (%s) as of %s: %s %s High: %s Low: %s" % (quote['Name'], msg, quote['Timestamp'], quote['LastPrice'], changepercent, quote['High'],
35+
quote['Low'])
3536

3637

3738
def random_stock():

cslbot/commands/tumblr.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ def cmd(send, msg, args):
5151
return
5252
# No random post functionality and we can only get 20 posts per API call, so pick a random offset to get the random post
5353
offset = randint(0, postcount - 1)
54-
response = get('https://api.tumblr.com/v2/blog/%s/posts' % cmdargs.blogname, params={'api_key': apikey, 'offset': offset, 'limit': 1, 'type': 'text', 'filter': 'text'}).json()
54+
response = get('https://api.tumblr.com/v2/blog/%s/posts' % cmdargs.blogname,
55+
params={'api_key': apikey,
56+
'offset': offset,
57+
'limit': 1,
58+
'type': 'text',
59+
'filter': 'text'}).json()
5560
entry = response['response']['posts'][0]['body']
5661
# Account for possibility of multiple lines
5762
lines = entry.splitlines()
@@ -70,7 +75,8 @@ def cmd(send, msg, args):
7075
row = Tumblrs(post=cmdargs.submit, submitter=args['nick'], nick=args['nick'], blogname=cmdargs.blogname)
7176
args['db'].add(row)
7277
args['db'].flush()
73-
send("New Tumblr Post: %s -- %s, Submitted by %s" % (cmdargs.submit, cmdargs.blogname, args['nick']), target=args['config']['core']['ctrlchan'])
78+
send("New Tumblr Post: %s -- %s, Submitted by %s" % (cmdargs.submit, cmdargs.blogname, args['nick']),
79+
target=args['config']['core']['ctrlchan'])
7480
send("Issue submitted for approval.", target=args['nick'])
7581
else:
7682
send("Did not get an argument (choices are --random, --submit)")

cslbot/commands/wai.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def cmd(send, *_):
2828
2929
"""
3030
a = ["primary", "secondary", "tertiary", "hydraulic", "compressed", "required", "pseudo", "intangible", "flux"]
31-
b = ["compressor", "engine", "lift", "elevator", "irc bot", "stabilizer", "computer", "ahamilto", "csl", "4506", "router", "switch", "thingy", "capacitor"]
32-
c = ["broke", "exploded", "corrupted", "melted", "froze", "died", "reset", "was seen by the godofskies", "burned", "corroded", "reversed polarity", "was accidentallied", "nuked"]
31+
b = ["compressor", "engine", "lift", "elevator", "irc bot", "stabilizer", "computer", "ahamilto", "csl", "4506", "router", "switch", "thingy",
32+
"capacitor"]
33+
c = ["broke", "exploded", "corrupted", "melted", "froze", "died", "reset", "was seen by the godofskies", "burned", "corroded",
34+
"reversed polarity", "was accidentallied", "nuked"]
3335
send("because %s %s %s" % ((choice(a), choice(b), choice(c))))

cslbot/commands/weather.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def get_weather(cmdargs, send, apikey):
9595
'relative_humidity': '60%',
9696
'pressure_in': '29.98',
9797
'wind_string': 'Calm'}
98-
forecastdata = {'conditions': 'Thunderstorms... Extreme Thunderstorms... Plague of Insects... The Rapture... Anti-Christ', 'high': {'fahrenheit': '3841'}, 'low': {'fahrenheit': '-6666'}}
98+
forecastdata = {'conditions': 'Thunderstorms... Extreme Thunderstorms... Plague of Insects... The Rapture... Anti-Christ',
99+
'high': {'fahrenheit': '3841'},
100+
'low': {'fahrenheit': '-6666'}}
99101
alertdata = {'alerts': [{'description': 'Apocalypse', 'expires': 'at the end of days'}]}
100102
elif 'results' in data['response']:
101103
send("%d results found, please be more specific" % len(data['response']['results']))
@@ -117,8 +119,8 @@ def get_weather(cmdargs, send, apikey):
117119
return False
118120
forecastdata = forecastdata['forecast']['simpleforecast']['forecastday'][0]
119121
send("Current weather for %s:" % data['display_location']['full'])
120-
current = '%s, Temp: %s (Feels like %s), Humidity: %s, Pressure: %s", Wind: %s' % (data['weather'], data['temp_f'], data['feelslike_f'], data['relative_humidity'], data['pressure_in'],
121-
data['wind_string'])
122+
current = '%s, Temp: %s (Feels like %s), Humidity: %s, Pressure: %s", Wind: %s' % (
123+
data['weather'], data['temp_f'], data['feelslike_f'], data['relative_humidity'], data['pressure_in'], data['wind_string'])
122124
forecast = '%s, High: %s, Low: %s' % (forecastdata['conditions'], forecastdata['high']['fahrenheit'], forecastdata['low']['fahrenheit'])
123125
send(current)
124126
send("Forecast: %s" % forecast)

cslbot/commands/wisdom.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def cmd(send, msg, args):
6060

6161
if cmdargs.query:
6262
cmdargs.query = ' '.join(cmdargs.query)
63-
req = get("http://www.stands4.com/services/v2/quotes.php", params={'uid': uid, 'tokenid': token, 'query': cmdargs.query, 'searchtype': searchtype})
63+
req = get("http://www.stands4.com/services/v2/quotes.php",
64+
params={'uid': uid,
65+
'tokenid': token,
66+
'query': cmdargs.query,
67+
'searchtype': searchtype})
6468
xml = etree.fromstring(req.content, parser=etree.XMLParser(recover=True))
6569
if len(xml) == 0:
6670
send("No words of wisdom found")

cslbot/helpers/core.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def __init__(self, confdir):
7979
self.server = server.init_server(self)
8080

8181
def handle_event(self, c, e):
82-
handled_types = ['account', 'action', 'authenticate', 'bannedfromchan', 'cap', 'ctcpreply', 'error', 'featurelist', 'join', 'kick', 'mode', 'nicknameinuse', 'nosuchnick', 'nick', 'part',
83-
'privmsg', 'privnotice', 'pubnotice', 'pubmsg', 'topic', 'welcome', 'whospcrpl']
82+
handled_types = ['account', 'action', 'authenticate', 'bannedfromchan', 'cap', 'ctcpreply', 'error', 'featurelist', 'join', 'kick', 'mode',
83+
'nicknameinuse', 'nosuchnick', 'nick', 'part', 'privmsg', 'privnotice', 'pubnotice', 'pubmsg', 'topic', 'welcome',
84+
'whospcrpl']
8485
# We only need to do stuff for a sub-set of events.
8586
if e.type not in handled_types:
8687
return

cslbot/helpers/handler.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ def handle_msg(self, c, e):
622622
def send(msg, mtype='privmsg', target=target, ignore_length=False):
623623
self.send(target, self.connection.real_nickname, msg, mtype, ignore_length)
624624

625-
if e.type in ['account', 'authenticate', 'bannedfromchan', 'cap', 'ctcpreply', 'error', 'featurelist', 'nosuchnick', 'nick', 'nicknameinuse', 'privnotice', 'welcome', 'whospcrpl']:
625+
if e.type in ['account', 'authenticate', 'bannedfromchan', 'cap', 'ctcpreply', 'error', 'featurelist', 'nosuchnick', 'nick', 'nicknameinuse',
626+
'privnotice', 'welcome', 'whospcrpl']:
626627
self.handle_event(msg, send, c, e)
627628
return
628629

cslbot/helpers/identity.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def get_chain(session, nick, limit=0):
3434
curr_time = datetime.now()
3535
curr = nick
3636
while curr is not None:
37-
row = session.query(Log).filter(Log.msg == curr, Log.type == 'nick', ~Log.source.startswith('Guest'), Log.time < curr_time, Log.time >= limit).order_by(Log.time.desc()).limit(1).first()
37+
row = session.query(Log).filter(Log.msg == curr, Log.type == 'nick', ~Log.source.startswith('Guest'), Log.time < curr_time,
38+
Log.time >= limit).order_by(Log.time.desc()).limit(1).first()
3839
if row is not None:
3940
curr = row.source
4041
chain.append(curr)

cslbot/helpers/misc.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ def parse_time(time):
4242
time = int(time)
4343
else:
4444
return None
45-
conv = {'s': 1, 'm': 60, 'h': timedelta(hours=1).total_seconds(), 'd': timedelta(days=1).total_seconds(), 'w': timedelta(weeks=1).total_seconds(), 'y': timedelta(weeks=52).total_seconds()}
45+
conv = {'s': 1,
46+
'm': 60,
47+
'h': timedelta(hours=1).total_seconds(),
48+
'd': timedelta(days=1).total_seconds(),
49+
'w': timedelta(weeks=1).total_seconds(),
50+
'y': timedelta(weeks=52).total_seconds()}
4651
if unit in conv.keys():
4752
return time * conv[unit]
4853
else:
@@ -136,7 +141,10 @@ def get_cmdchar(config, connection, msg, msgtype):
136141

137142

138143
def parse_header(header, msg):
139-
proc = subprocess.run(['gcc', '-include', '%s.h' % header, '-fdirectives-only', '-E', '-xc', '/dev/null'], stdout=subprocess.PIPE, universal_newlines=True, check=True)
144+
proc = subprocess.run(['gcc', '-include', '%s.h' % header, '-fdirectives-only', '-E', '-xc', '/dev/null'],
145+
stdout=subprocess.PIPE,
146+
universal_newlines=True,
147+
check=True)
140148
if header == 'errno':
141149
defines = re.findall('^#define (E[A-Z]*) ([0-9]+)', proc.stdout, re.MULTILINE)
142150
else:

0 commit comments

Comments
 (0)