Skip to content

Instantly share code, notes, and snippets.

@BarelyMiSSeD
Created March 9, 2015 17:45
Show Gist options
  • Save BarelyMiSSeD/c21e9706b057aa376ad3 to your computer and use it in GitHub Desktop.
Save BarelyMiSSeD/c21e9706b057aa376ad3 to your computer and use it in GitHub Desktop.
import minqlbot
class protect(minqlbot.Plugin):
def __init__(self):
super().__init__()
self.add_hook("vote_called", self.handle_vote_called)
self.add_command("protect", self.cmd_protect, 4, usage="<full_name>")
def handle_vote_called(self, caller, vote, args):
if vote == "kick":
if args == minqlbot.NAME.lower():
self.vote_no()
else:
found_word = 0
f = open("python/plugins/nokick.txt", "r")
g = f.readlines()
f.close()
for text_word in g:
if hash(args) == hash(text_word.lower().rstrip()):
found_word += 1
if found_word == 1:
self.vote_no()
def cmd_protect(self, player, msg):
self.msg("Start")
if len(msg) < 2:
return minqlbot.RET_USAGE
name = self.clean_text(msg[2])
action = self.clean_text(msg[1])
if action == "add":
if not action: return minqlbot.RET_USAGE
found_word = 0
f = open("python/plugins/nokick.txt", "r")
g = f.readlines()
f.close()
for text_word in g:
if hash(name) == hash(text_word.lower().rstrip()):
found_word += 1
if found_word == 1:
self.tell("{} is already in the nokick list.".format(name), player)
return
h = open("python/plugins/nokick.txt", "a")
h.write(name)
h.close()
self.tell("{} has been added to the nokick list.".format(name), player)
elif action == "del":
if not action: return minqlbot.RET_USAGE
found_word = 0
f = open("python/plugins/nokick.txt", "r")
g = f.readlines()
f.close()
for text_word in g:
if hash(name) == hash(text_word.lower().rstrip()):
found_word += 1
if found_word == 1:
h = open("python/plugins/nokick.txt", "w")
for line in g:
if hash(name) != hash(line.lower().rstrip()):
h.write(line)
h.close()
self.tell("{} has been deleted from the nokick list.".format(name), player)
return
self.tell("{} is not in the nokick list.".format(name), player)
elif action == "check":
if not action: return minqlbot.RET_USAGE
f = open("python/plugins/nokick.txt", "r")
g = f.readlines()
f.close()
for text_word in g:
if hash(name) == hash(text_word.lower().rstrip()):
found_word += 1
if found_word == 1:
self.tell("{} is in the nokick list.".format(name), player)
return
self.tell("{} is NOT in the nokick list.".format(name), player)
elif action == "list":
f = open("python/plugins/nokick.txt", "r")
g = f.readlines()
f.close()
self.tell(g, player)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment