1
0
Fork 0
forked from swee/MeowNex

change the way bot restarts, 2 others

* fix $welcome
* change version
This commit is contained in:
Nova Cat 2024-11-17 15:07:44 -08:00
parent 2eb86d97bd
commit 41ed4a1090

View file

@ -1,4 +1,4 @@
__version__ = "0.0.1 Link parser update" __version__ = "0.0.2 Funni update"
import socket import socket
import subprocess import subprocess
from time import sleep, time, ctime from time import sleep, time, ctime
@ -173,7 +173,7 @@ class bot_irc:
) )
except: except:
pass pass
server_irc = "127.0.0.1" # Use 127.0.0.1 for local ZNC server_irc = "127.0.0.1" # Use 127.0.0.1 for local ZNC
port_irc = 6667 # NO SSL FOR YOU port_irc = 6667 # NO SSL FOR YOU
@ -198,7 +198,7 @@ times = 0
def update(): def update():
open(str(Path.home()) + "/run.txt", 'w').write(str(run)) open(str(Path.home()) + "/run.txt", 'w').write(str(run))
open(str(Path.home()) + "/block.txt", 'w').write(str(block)) open(str(Path.home()) + "/block.txt", 'w').write(str(block))
update() update()
def irci2(): def irci2():
irc2.connect_irc( irc2.connect_irc(
@ -235,12 +235,11 @@ def multiline(text, channel):
sleep(1) sleep(1)
irc.send_irc(channel, replace_color_codes(t)) irc.send_irc(channel, replace_color_codes(t))
times += 1 times += 1
from sys import argv, exit from sys import exit
def restart(): def restart():
irc.irc_socket.close() irc.irc_socket.close()
irc2.irc_socket.close() irc2.irc_socket.close()
irc3.irc_socket.close() irc3.irc_socket.close()
ossystem("python " + " ".join(argv))
exit(0) exit(0)
def system(cmd, chan): def system(cmd, chan):
try: try:
@ -254,9 +253,9 @@ def system(cmd, chan):
multiline(cmd[0] + " not found", chan) multiline(cmd[0] + " not found", chan)
except: except:
multiline(traceback.format_exc()) multiline(traceback.format_exc())
irl2 = threading.Thread(target=irci2) irl2 = threading.Thread(target=irci2, daemon=True)
irl2.start() irl2.start()
irl3 = threading.Thread(target=irci3) irl3 = threading.Thread(target=irci3, daemon=True)
irl3.start() irl3.start()
while True: while True:
teext = irc.response_irc().split("\r\n") teext = irc.response_irc().split("\r\n")
@ -316,22 +315,23 @@ while True:
multiline(output, channel) multiline(output, channel)
else: else:
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(["fortune"], channel) system(["fortune"], channel)
elif command[0] == "$whoami": elif command[0] == "$whoami":
if perms != "": if perms != "":
irc.send_irc(channel, nick + ": " + username + " (Your cloak has permissions, use the 'perms' command to see)") irc.send_irc(channel, nick + ": " + username + " (Your cloak has permissions, use the 'perms' command to see)")
else: else:
irc.send_irc(channel, nick + ": " + username) irc.send_irc(channel, nick + ": " + username)
elif command[0] == "$welcome": elif command[0] == "$welcome":
name = nick if not len(command) > 1 else " ".join(command[1:])
if random(1,2) == 1: if random(1,2) == 1:
irc.send_irc(channel, "Heyo! Welcome to the channel," + command[1]) irc.send_irc(channel, "Heyo! Welcome to the channel, {name}")
else: else:
irc.send_irc(channel, "Welcome, " + command[1]) irc.send_irc(channel, "Welcome, {name}")
elif command[0] == "$perms": elif command[0] == "$perms":
if len(command) == 2: if len(command) == 2:
if sbconfig.perms(command[1]) != "": if sbconfig.perms(command[1]) != "":
@ -354,7 +354,7 @@ while True:
block+=1 block+=1
run-=1 run-=1
update() update()
elif command[0] == "$pull": elif command[0] == "$pull":
if perms == "full" or "git" in perms.split(","): if perms == "full" or "git" in perms.split(","):
ossystem("git fetch") ossystem("git fetch")
@ -386,7 +386,7 @@ while True:
block+=1 block+=1
run-=1 run-=1
update() update()
elif command[0] == "$part": elif command[0] == "$part":
if perms == "full" or "part" in perms.split(","): if perms == "full" or "part" in perms.split(","):
if len(command) == 2: if len(command) == 2:
@ -408,7 +408,7 @@ while True:
block+=1 block+=1
run-=1 run-=1
update() update()
elif command[0] == "$socket": elif command[0] == "$socket":
if perms == "full": if perms == "full":
if len(command) > 1: if len(command) > 1:
@ -423,8 +423,8 @@ while True:
block+=1 block+=1
run-=1 run-=1
update() update()
elif command[0] == "$shell": elif command[0] == "$shell":
if perms == "full": if perms == "full":
#or "shell" in perms.split(",") #or "shell" in perms.split(",")
@ -440,10 +440,10 @@ while True:
block+=1 block+=1
run-=1 run-=1
update() update()
elif command[0] == "$version": elif command[0] == "$version":
irc.send_irc(channel, "This is SweeBot " + __version__) irc.send_irc(channel, "This is SweeBot " + __version__)
elif command[0] == "$figlet": elif command[0] == "$figlet":
if not sbconfig.cflagexist(channel, "-multiline"): if not sbconfig.cflagexist(channel, "-multiline"):
if len(command) > 1: if len(command) > 1:
@ -491,7 +491,7 @@ while True:
system(['pyjoke'] + command[1:], channel) system(['pyjoke'] + command[1:], channel)
except Exception as ex: except Exception as ex:
multiline(traceback.format_exc(), channel) multiline(traceback.format_exc(), channel)
elif command[0] == "$botsnack": elif command[0] == "$botsnack":
multiline(f"\x01ACTION eats some {choice(snacks)}\x01", channel) multiline(f"\x01ACTION eats some {choice(snacks)}\x01", channel)
elif command[0] == "$hug": elif command[0] == "$hug":
@ -539,7 +539,7 @@ while True:
# else: # else:
# irc.send_irc(channel, nick + ": What to correct?") # irc.send_irc(channel, nick + ": What to correct?")
elif command[0] == "$config": elif command[0] == "$config":
try: try:
if len(command) > 1: if len(command) > 1:
@ -576,7 +576,7 @@ while True:
multiline("Configuration for " + channel + ": " + " ".join(sbconfig.chansettings(channel)), channel) multiline("Configuration for " + channel + ": " + " ".join(sbconfig.chansettings(channel)), channel)
except ex: except ex:
multiline(str(ex), channel) multiline(str(ex), channel)
else: else:
if ".." in command[0][:3]: if ".." in command[0][:3]:
irc.send_irc(channel, nick + ": Nice try.") irc.send_irc(channel, nick + ": Nice try.")
@ -605,7 +605,7 @@ while True:
else: else:
print(nick + ": Unrecognised command") print(nick + ": Unrecognised command")
elif command[0] == ":3": elif command[0] == ":3":
if not sbconfig.cflagexist(channel, "-colonthree"): if not sbconfig.cflagexist(channel, "-colonthree"):
irc.send_irc(channel, ":3") irc.send_irc(channel, ":3")