Fix for the spammyness of !alts add <list>

Added the old broadcast module back
fix for !wants list
This commit is contained in:
2021-10-22 19:44:26 +02:00
parent bb445e868d
commit bd8055dac7
6 changed files with 120 additions and 29 deletions
+26 -20
View File
@@ -60,30 +60,36 @@ class AltsController:
@command(command="alts", params=[Const("add"), Multiple(Character("character"))], access_level="member",
description="Add an alt")
def alts_add_cmd(self, request, _, alt_chars):
responses = []
for alt_char in alt_chars:
if not alt_char.char_id:
responses.append(self.getresp("global", "char_not_found", {"char": alt_char.name}))
continue
elif alt_char.char_id == request.sender.char_id:
responses.append(self.getresp("module/alts", "add_fail_self"))
continue
manual = self.setting_service.get_value("alt_verification") == "1"
if manual:
responses.append(self.register_controller.register_alt(request, _, alt_char))
continue
msg, result = self.account_service.add_alt(request.sender.char_id, alt_char.char_id)
notfound = []
done = []
failed = []
gotalts = []
main = self.account_service.get_main(request.sender.char_id)
for alt in alt_chars:
if not alt.char_id:
notfound.append(alt)
continue
if main.char_id == alt.char_id:
failed.append(self.getresp("module/alts", "add_fail_self"))
continue
msg, result = self.account_service.add_alt(main.char_id, alt.char_id)
if result:
self.bot.send_mass_message(alt_char.char_id, self.getresp("module/alts", "add_success_target",
{"char": request.sender.name}))
responses.append(self.getresp("module/alts", "add_success_self", {"char": alt_char.name}))
done.append(alt.name)
self.bot.send_mass_message(alt.char_id, self.getresp("module/alts", "add_success_target", {"char": main.name}))
elif msg == "another_main":
responses.append(self.getresp("module/alts", "add_fail_already", {"char": alt_char.name}))
else:
raise Exception("Unknown msg: " + msg)
gotalts.append(alt.name)
return "\n".join(responses)
reply = ""
if len(done) > 0:
reply += self.getresp("module/alts", "add_success_self",
{"char": ", ".join(done)})
if len(notfound) > 0:
reply += "\n" + self.getresp("global", "char_not_found", {"char": ", ".join(notfound)})
if len(gotalts) > 0:
reply += "\n" + self.getresp("module/alts", "add_fail_already", {"char": ", ".join(gotalts)})
reply += "\n".join(failed)
return reply
@command(command="alts", params=[Options(["rem", "remove"]), Character("character")], access_level="member",
description="Remove an alt")