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