forked from swee/MeowNex
Prepare for contribution #1
1 changed files with 9 additions and 3 deletions
12
sweebot.py
12
sweebot.py
|
@ -273,12 +273,18 @@ def restart():
|
|||
irc2.irc_socket.close()
|
||||
irc3.irc_socket.close()
|
||||
exit(0)
|
||||
def system(cmd, chan):
|
||||
def system(cmd, chan, rstrip=False):
|
||||
try:
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
outpp = ""
|
||||
for line in iter(p.stdout.readline, b''):
|
||||
if text != "" and text != " ":
|
||||
multiline(line.rstrip(), chan)
|
||||
if not rstrip
|
||||
multiline(line.rstrip(), chan)
|
||||
else:
|
||||
outpp += line.rstrip() + " "
|
||||
if rstrip:
|
||||
multiline(outpp[:-1])
|
||||
p.stdout.close()
|
||||
p.wait()
|
||||
except FileNotFoundError:
|
||||
|
@ -349,7 +355,7 @@ while True:
|
|||
irc.send_irc(channel, "tip, ping, whoami, perms, version, figlet, tdfiglet, cowsay, uptime, cc, joke, botsnack. (restart, join, part, shell, config, pull.) Use '$help (command)' for explanation.")
|
||||
|
||||
elif command[0] == "$tip":
|
||||
system(["/usr/games/fortune", "debian-hints"], channel)
|
||||
system(["/usr/games/fortune", "debian-hints"], channel, True)
|
||||
|
||||
elif command[0] == "$whoami":
|
||||
if perms != "":
|
||||
|
|
Loading…
Reference in a new issue