!latest command to allow regex searches
This commit is contained in:
parent
e8c758cd0f
commit
3f97194d36
10
bot.py
10
bot.py
|
@ -71,11 +71,11 @@ class CosmicBot(teambot.Handler):
|
|||
line = re.sub("\s+"," ",line).split(" ",1)
|
||||
self.say(channel,"{}: {} (by {})".format(nick,line[1],unhighlight_nick(line[0])))
|
||||
def on_latest(self,channel,nick,count=5):
|
||||
count = int(count)
|
||||
if count < 1:
|
||||
count = 1 # ...nice try, smartass
|
||||
if count > 5:
|
||||
count = 5 # don't spam the channel
|
||||
if isinstance(count, int):
|
||||
if count < 1:
|
||||
count = 1 # ...nice try, smartass
|
||||
if count > 5:
|
||||
count = 5 # don't spam the channel
|
||||
self.say(channel, "{}: Latest {} {}. (See cosmic.voyage for more!)".format(nick, count, (count == 1 and "entry" or "entries")))
|
||||
output = subprocess.check_output(["/usr/local/bin/latest",str(count)]).decode("ascii").split("\n")
|
||||
output = filter(None,output)
|
||||
|
|
Loading…
Reference in New Issue