def execute(self, message, user, params): pnicks = params.group(1) access = params.group(2) if not access.isdigit(): try: access = Config.getint("Access",access) except Exception: message.reply("Invalid access level '%s'" % (access,)) return else: access = int(access) if access > user.access: message.reply("You may not add a user with higher access to your own") return added = [] exists = [] for pnick in pnicks.split(): if pnick.lower() == Config.get("Connection","nick").lower(): message.reply("I am already here, shitface.") continue member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=user.name) session.add(member) added.append(pnick) elif not member.active: member.active = True member.access = access member.sponsor = user.name added.append(pnick) elif not member.is_member(): member.access = access member.sponsor = user.name added.append(pnick) else: exists.append(pnick) session.commit() if len(exists): message.reply("Users (%s) already exist" % (",".join(exists),)) # Bot access if len(added): message.reply("Added users (%s) at level %s" % (",".join(added),access)) # P access with netgamers.org (set up to adduser with access 100 to your Home channel from merlin.cfg) if len(added) and access == Config.getint("Access","member"): message.privmsg("adduser %s %s 100" %(Config.get("Channels","home"), ",".join(added),), "P") message.reply("Added users (%s) to %s with lvl 100 access" % (",".join(added), Config.get("Channels","home"))) if len(added) and access >= Config.getint("Access","core"): message.privmsg("adduser %s %s 150" %(Config.get("Channels","home"), ",".join(added),), "P") message.reply("Added users (%s) to %s with lvl 150 access" % (",".join(added), Config.get("Channels","home"))) message.privmsg("adduser %s %s 150" %(Config.get("Channels","core"), ",".join(added),), "P") message.reply("Added users (%s) to %s with lvl 150 access" % (",".join(added), Config.get("Channels","core")))
def execute(self, message, user, params): pnicks = params.group(1) access = params.group(2) if not access.isdigit(): try: access = Config.getint("Access", access) except Exception: message.reply("Invalid access level '%s'" % (access, )) return else: access = int(access) if access > user.access: message.reply( "You may not add a user with higher access to your own") return added = [] exists = [] for pnick in pnicks.split(): if pnick.lower() == Config.get("Connection", "nick").lower(): message.reply("I am already here, shitface.") continue member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=user.name) session.add(member) added.append(pnick) elif not member.active: member.active = True member.access = access member.sponsor = user.name added.append(pnick) elif not member.is_member(): member.access = access member.sponsor = user.name added.append(pnick) else: exists.append(pnick) session.commit() if len(exists): message.reply("Users (%s) already exist" % (",".join(exists), )) if len(added): message.reply("Added users (%s) at level %s" % (",".join(added), access)) if len(added) and access >= Config.getint("Access", "member"): message.privmsg( "adduser %s %s 24" % ( Config.get("Channels", "home"), ",".join(added), ), Config.get("Services", "nick"))
def execute(self, message, user, params): pnicks = params.group(1) access = params.group(2) if not access.isdigit(): try: access = Config.getint("Access",access) except Exception: message.reply("Invalid access level '%s'" % (access,)) return else: access = int(access) if access > user.access: message.reply("You may not add a user with higher access to your own") return added = [] exists = [] for pnick in pnicks.split(): member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=user.name) session.add(member) added.append(pnick) elif not member.active: member.active = True member.access = access member.sponsor = user.name added.append(pnick) elif not member.is_member(): member.access = access member.sponsor = user.name added.append(pnick) else: exists.append(pnick) session.commit() if len(exists): message.reply("Users (%s) already exist" % (",".join(exists),)) if len(added): message.reply("Added users (%s) at level %s" % (",".join(added),access)) if len(added) and access >= Config.getint("Access","member"): message.privmsg("adduser %s %s 399" %(Config.get("Channels","home"), ",".join(added),), "P")
def expire(self, message, user, params): id = params.group(1) prop = self.load_prop(id) if prop is None: message.reply("No proposition number %s exists (idiot)."%(id,)) return if not prop.active: message.reply("You can't expire prop %d, it's already expired."%(prop.id,)) return if prop.proposer is not user and not user.is_admin(): message.reply("Only %s may expire proposition %d."%(prop.proposer.name,prop.id)) return if prop.type == "invite" and not self.member_count_below_limit(): message.reply("You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you."%(Config.getint("Alliance", "members"),)) return self.recalculate_carebears(prop) yes, no, veto = self.sum_votes(prop) passed = yes > no and veto <= 0 vote_result = ['no','yes'][passed] reply = self.text_result(vote_result, yes, no, veto) reply+= self.text_summary(prop) message.reply(reply) if prop.type == "invite" and passed: pnick = prop.person access = Config.getint("Access", "member") member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=prop.proposer.name) session.add(member) elif not member.active: member.active = True member.access = access member.sponsor = prop.proposer.name elif not member.is_member(): member.access = access member.sponsor = prop.proposer.name message.privmsg("adduser %s %s 24" %(Config.get("Channels","home"), pnick,), Config.get("Services", "nick")) message.reply("%s has been added to %s and given member level access to me."%(pnick,Config.get("Channels","home"))) if prop.type == "kick" and passed: idiot = prop.kicked if "galmate" in Config.options("Access"): idiot.access = Config.getint("Access","galmate") else: idiot.access = 0 if idiot.planet is not None and idiot.planet.intel is not None: intel = idiot.planet.intel alliance = Alliance.load(Config.get("Alliance","name")) if intel.alliance == alliance: intel.alliance = None message.privmsg("remuser %s %s"%(Config.get("Channels","home"), idiot.name,),Config.get("Services", "nick")) # message.privmsg("ban %s *!*@%s.%s Your sponsor doesn't like you anymore"%(Config.get("Channels","home"), idiot.name, Config.get("Services", "usermask"),),Config.get("Services", "nick")) message.privmsg("note send %s A proposition to kick you from %s has been raised by %s with reason '%s' and passed by a vote of %s to %s."%(idiot.name,Config.get("Alliance","name"),prop.proposer.name,prop.comment_text,yes,no),Config.get("Services", "nick")) message.reply("%s has been reduced to \"galmate\" level and removed from the channel."%(idiot.name,)) if prop.type == "suggestion" and passed: message.reply("Suggestion \"%s\" has passed" %(prop.comment_text)) prop.active = False prop.closed = current_timestamp() prop.vote_result = vote_result session.commit()
def execute2(self, message, user, params): mode = params.group(1).lower() if mode == "invite": person = params.group(2) u = User.load(name=person,access="member") if u is not None: message.reply("Stupid %s, that wanker %s is already a member."%(user.name,person)) return if self.is_already_proposed_invite(person): message.reply("Silly %s, there's already a proposal to invite %s."%(user.name,person)) return if not self.member_count_below_limit(): message.reply("You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you."%(Config.getint("Alliance", "members"),)) return anc = user.has_ancestor(person) if anc is True: message.reply("Ew, incest.") return if anc is None: message.reply("Filthy orphans should be castrated.") return prop = Invite(proposer=user, person=person, comment_text=params.group(3)) session.add(prop) session.commit() reply = "%s created a new proposition (nr. %d) to invite %s." %(user.name, prop.id, person) reply+= " When people have been given a fair shot at voting you can call a count using !prop expire %d."%(prop.id,) message.reply(reply) elif mode == "kick": person = params.group(2) if person.lower() == Config.get("Connection","nick").lower(): message.reply("I'll peck your eyes out, c**t.") return u = User.load(name=person,access="member") if u is None: message.reply("Stupid %s, you can't kick %s, they're not a member."%(user.name,person)) return if self.is_already_proposed_kick(person): message.reply("Silly %s, there's already a proposal to kick %s."%(user.name,person)) return if u.access > user.access: message.reply("Unfortunately I like %s more than you. So none of that."%(u.name,)) return prop = Kick(proposer=user, kicked=u, comment_text=params.group(3)) session.add(prop) session.commit() reply = "%s created a new proposition (nr. %d) to kick %s." %(user.name, prop.id, person) reply+= " When people have been given a fair shot at voting you can call a count using !prop expire %d."%(prop.id,) message.reply(reply) elif mode == "expire": id = params.group(2) prop = self.load_prop(id) if prop is None: message.reply("No proposition number %s exists (idiot)."%(id,)) return if prop.proposer is not user and not user.is_admin(): message.reply("Only %s may expire proposition %d."%(prop.proposer.name,id)) return if prop.type == "invite" and not self.member_count_below_limit(): message.reply("You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you."%(Config.getint("Alliance", "members"),)) return self.recalculate_carebears(prop) yes, no, veto = self.sum_votes(prop) passed = yes > no and veto <= 0 vote_result = ['no','yes'][passed] reply = self.text_result(vote_result, yes, no, veto) reply+= self.text_summary(prop) message.reply(reply) if prop.type == "invite" and passed: pnick = prop.person access = Config.getint("Access", "member") member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=prop.proposer.name) session.add(member) elif not member.active: member.active = True member.access = access member.sponsor = prop.proposer.name elif not member.is_member(): member.access = access member.sponsor = prop.proposer.name message.privmsg("adduser %s %s 399" %(Config.get("Channels","home"), pnick,), "P") message.reply("%s has been added to %s and given member level access to me."%(pnick,Config.get("Channels","home"))) if prop.type == "kick" and passed: idiot = prop.kicked if "galmate" in Config.options("Access"): idiot.access = Config.getint("Access","galmate") else: idiot.access = 0 if idiot.planet is not None and idiot.planet.intel is not None: intel = idiot.planet.intel alliance = Alliance.load(Config.get("Alliance","name")) if intel.alliance == alliance: intel.alliance = None message.privmsg("remuser %s %s"%(Config.get("Channels","home"), idiot.name,),'p') message.privmsg("ban %s *!*@%s.users.netgamers.org Your sponsor doesn't like you anymore"%(Config.get("Channels","home"), idiot.name,),'p') message.privmsg("note send %s A proposition to kick you from %s has been raised by %s with reason '%s' and passed by a vote of %s to %s."%(idiot.name,Config.get("Alliance","name"),prop.proposer.name,prop.comment_text,yes,no),'p') message.reply("%s has been reduced to \"galmate\" level and removed from the channel."%(idiot.name,)) prop.active = False prop.closed = current_timestamp() prop.vote_result = vote_result session.commit() elif mode == "cancel": id = params.group(2) prop = self.load_prop(id) if prop is None: message.reply("No proposition number %s exists (idiot)."%(id,)) return if prop.proposer is not user and not user.is_admin(): message.reply("Only %s may expire proposition %d."%(prop.proposer.name,id)) return vote_result = "cancel" reply = self.text_result(vote_result, yes, no, veto) reply+= self.text_summary(prop) message.reply(reply) prop.active = False prop.closed = current_timestamp() prop.vote_result = vote_result session.commit()
def expire(self, message, user, params): id = params.group(1) prop = self.load_prop(id) if prop is None: message.reply("No proposition number %s exists (idiot)." % (id, )) return if not prop.active: message.reply("You can't expire prop %d, it's already expired." % (prop.id, )) return if prop.proposer is not user and not user.is_admin(): message.reply("Only %s may expire proposition %d." % (prop.proposer.name, prop.id)) return if prop.type == "invite" and not self.member_count_below_limit(): message.reply( "You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you." % (Config.getint("Alliance", "members"), )) return self.recalculate_carebears(prop) yes, no, veto = self.sum_votes(prop) passed = yes > no and veto <= 0 vote_result = ['no', 'yes'][passed] reply = self.text_result(vote_result, yes, no, veto) reply += self.text_summary(prop) message.reply(reply) if prop.type == "invite" and passed: pnick = prop.person access = Config.getint("Access", "member") member = User.load(name=pnick, active=False) if member is None: member = User(name=pnick, access=access, sponsor=prop.proposer.name) session.add(member) elif not member.active: member.active = True member.access = access member.sponsor = prop.proposer.name elif not member.is_member(): member.access = access member.sponsor = prop.proposer.name message.privmsg( "adduser %s %s 24" % ( Config.get("Channels", "home"), pnick, ), Config.get("Services", "nick")) message.reply( "%s has been added to %s and given member level access to me." % (pnick, Config.get("Channels", "home"))) if prop.type == "kick" and passed: idiot = prop.kicked if "galmate" in Config.options("Access"): idiot.access = Config.getint("Access", "galmate") else: idiot.access = 0 if idiot.planet is not None and idiot.planet.intel is not None: intel = idiot.planet.intel alliance = Alliance.load(Config.get("Alliance", "name")) if intel.alliance == alliance: intel.alliance = None message.privmsg( "remuser %s %s" % ( Config.get("Channels", "home"), idiot.name, ), Config.get("Services", "nick")) # message.privmsg("ban %s *!*@%s.%s Your sponsor doesn't like you anymore"%(Config.get("Channels","home"), idiot.name, Config.get("Services", "usermask"),),Config.get("Services", "nick")) message.privmsg( "note send %s A proposition to kick you from %s has been raised by %s with reason '%s' and passed by a vote of %s to %s." % (idiot.name, Config.get("Alliance", "name"), prop.proposer.name, prop.comment_text, yes, no), Config.get("Services", "nick")) message.reply( "%s has been reduced to \"galmate\" level and removed from the channel." % (idiot.name, )) if prop.type == "suggestion" and passed: message.reply("Suggestion \"%s\" has passed" % (prop.comment_text)) prop.active = False prop.closed = current_timestamp() prop.vote_result = vote_result session.commit()