forked from swee/MeowNex
Update sweebot.py
This commit is contained in:
parent
e58abcda8d
commit
6b55d21f91
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()
|
irc2.irc_socket.close()
|
||||||
irc3.irc_socket.close()
|
irc3.irc_socket.close()
|
||||||
exit(0)
|
exit(0)
|
||||||
def system(cmd, chan):
|
def system(cmd, chan, rstrip=False):
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
outpp = ""
|
||||||
for line in iter(p.stdout.readline, b''):
|
for line in iter(p.stdout.readline, b''):
|
||||||
if text != "" and text != " ":
|
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.stdout.close()
|
||||||
p.wait()
|
p.wait()
|
||||||
except FileNotFoundError:
|
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.")
|
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":
|
elif command[0] == "$tip":
|
||||||
system(["/usr/games/fortune", "debian-hints"], channel)
|
system(["/usr/games/fortune", "debian-hints"], channel, True)
|
||||||
|
|
||||||
elif command[0] == "$whoami":
|
elif command[0] == "$whoami":
|
||||||
if perms != "":
|
if perms != "":
|
||||||
|
|
Loading…
Reference in a new issue