def process(session_id, fields): if fields and fields[0]: ACTION(actions.registration.Registration).confirm( session_id, fields[0]) else: ACTION(actions.registration.Registration).request_confirmation( session_id)
def process(session_id, fields): if fields[0] and not fields[0].isdigit(): raise LtdErrorException("Usage: /news {item}") if fields[0]: ACTION(actions.info.Info).news_item(session_id, int(fields[0]), msgid(fields)) else: ACTION(actions.info.Info).all_news(session_id, msgid(fields))
def process(session_id, fields): if fields[0] and not fields[0].isdigit(): raise LtdErrorException("Usage: /log {level}") if fields[0]: ACTION(actions.admin.Admin).set_log_level(session_id, int(fields[0]), msgid(fields)) else: ACTION(actions.admin.Admin).log_level(session_id, msgid(fields))
def process(session_id, fields): if fields[0]: if fields[0] == "-s": ACTION(actions.list.List).shortlist(session_id, with_members=True, msgid=msgid(fields)) elif fields[0] == "-g": ACTION(actions.list.List).shortlist(session_id, with_members=False, msgid=msgid(fields)) else: ACTION(actions.list.List).list_group(session_id, fields[0], msgid(fields)) else: ACTION(actions.list.List).list(session_id, msgid=msgid(fields))
def process(session_id, fields): if not fields[0]: raise LtdErrorException("Usage: /drop {nicknames}") nicks = [n.strip() for n in fields[0].split(" ")] ACTION(actions.admin.Admin).drop(session_id, nicks)
def process(session_id, fields): usage = "Usage: notify {-q} {-n nick|-s address}" if fields[0]: try: opts, target = ltd.get_opts(fields[0], quiet="q", mode="ns") if not target: raise LtdErrorException(usage) except: raise LtdErrorException(usage) ACTION(actions.notification.Notify).toggle(session_id, target, **opts) else: ACTION(actions.notification.Notify).list(session_id)
def process(session_id, fields): msg_fields = fields[0].split(" ") if len(msg_fields) == 2: nick, password = msg_fields ACTION(actions.admin.Admin).change_password( session_id, nick, password) else: raise LtdErrorException("Usage: /passwd {nick} {new password}")
def process(session_id, fields): msg_fields = fields[0].split(" ") if len(msg_fields) == 2: old_pwd, new_pwd = msg_fields ACTION(actions.registration.Registration).change_password( session_id, old_pwd, new_pwd) else: raise LtdErrorException("Usage: /cp {old password} {new password}")
def process(session_id, fields): msg_fields = fields[0].split(" ", 1) if len(msg_fields) == 2: receiver, message = [f.strip() for f in msg_fields] else: raise LtdErrorException("Usage: /write {nick} {message}") ACTION(actions.messagebox.MessageBox).send_message( session_id, receiver, message)
def process(session_id, fields): usage = "Usage: hush {-q} {-n nick|-s address}" if fields[0]: try: opts, target = ltd.get_opts(fields[0], quiet="q", mode="ns", msg_type="op") if not target: raise LtdErrorException(usage) except: raise LtdErrorException(usage) ACTION(actions.hush.Hush).toggle(session_id, target, **opts) else: ACTION(actions.hush.Hush).list(session_id)
def process(session_id, fields): msg_fields = fields[0].split(" ", 1) if len(msg_fields) == 2: receiver, message = [f.strip() for f in msg_fields] else: raise LtdErrorException("Usage: /m {nick} {message}") ACTION(actions.privatemessage.PrivateMessage).send( session_id, receiver, message)
def __change_idle_mod__(self, moderator, info, minutes): old_val = info.idle_mod info.idle_mod = minutes self.broker.to_channel(info.key, ltd.encode_status_msg("Change", "%s changed idle-mod to %s." % (moderator, info.idle_mod_str))) if old_val > minutes and minutes > 0 and info.moderator: mod_state = self.session.get(info.moderator) if mod_state.t_recv.elapsed() > (minutes * 60): ACTION(actions.usersession.UserSession).idle_mod(info.moderator)
def process(session_id, fields): msg_fields = fields[0].split(" ", 1) if len(msg_fields) == 2: receiver, message = [f.strip() for f in msg_fields] else: raise LtdErrorException("Usage: /exclude {nick} {message}") ACTION(actions.openmessage.OpenMessage).send(session_id, message, exclude=receiver)
def process(session_id, fields): fn = None args = [] if fields[3] == "login": fn = ACTION(actions.usersession.UserSession).login password = fields[4] if len(fields) >= 5 else "" status = fields[5] if len(fields) >= 6 else "" address = fields[6] if len(fields) >= 7 else "" args = [ session_id, fields[0], fields[1], password, fields[2], status, address ] elif fields[3] == "w": fn = ACTION(actions.list.List).list_and_quit args = [session_id] if not fn: raise LtdErrorException("Unsupported login type: '%s'" % fields[3]) fn(*args)
def process(session_id, fields): usage = "Usage: cancel {-q} {-n nick|-s address}" try: opts, nick = ltd.get_opts(fields[0], quiet="q", mode="ns") if not nick: raise LtdErrorException(usage) except: raise LtdErrorException(usage) ACTION(actions.group.Group).cancel(session_id, nick, **opts)
def process(session_id, fields): usage = "Usage: /stats {-s|-t|-m|-y|-a}" try: opts, rest = ltd.get_opts(fields[0], timeframe="stmya") if rest: raise LtdErrorException(usage) ACTION(actions.info.Info).stats(session_id, **opts, msgid=msgid(fields)) except LtdErrorException as ex: raise ex except: raise LtdErrorException(usage)
def boot(self, session_id, nick): info = self.__get_group_if_can_moderate__(session_id) loggedin_session = self.session.find_nick(nick) if loggedin_session == session_id: raise LtdErrorException("You cannot boot yourself.") if not loggedin_session: raise LtdErrorException("%s is not signed on." % nick) state = self.session.get(session_id) loggedin_state = self.session.get(loggedin_session) if loggedin_state.group.lower() != state.group.lower(): raise LtdErrorException("%s is not in your group." % nick) if loggedin_state.authenticated: with self.nickdb_connection.enter_scope() as scope: if self.nickdb.is_admin(scope, state.nick): self.broker.deliver(loggedin_session, ltd.encode_status_msg("Boot", "%s tried to boot you." % state.nick)) self.reputation.fatal(session_id) raise LtdErrorException("You cannot boot an admin.") try: info.cancel_nick(loggedin_state.nick) self.broker.deliver(session_id, ltd.encode_status_msg("FYI", "%s cancelled." % nick)) except KeyError: pass try: info.mute_nick(loggedin_state.nick) self.broker.deliver(session_id, ltd.encode_status_msg("FYI", "%s removed from talker list." % nick)) except KeyError: pass self.broker.to_channel(info.key, ltd.encode_status_msg("Boot", "%s was booted." % nick)) self.broker.deliver(loggedin_session, ltd.encode_status_msg("Boot", "%s booted you." % state.nick)) ACTION(actions.usersession.UserSession).join(loggedin_session, core.BOOT_GROUP) with self.statsdb_connection.enter_scope() as scope: self.statsdb.add_boot(scope) scope.complete()
def process(session_id, fields): usage = "Usage: talk {-q} {-d} {-r} {-n nick|-s address}" try: opts, nick = ltd.get_opts(fields[0], quiet="q", delete="d", registered="r", mode="ns") if not nick: raise LtdErrorException(usage) except: raise LtdErrorException(usage) ACTION(actions.group.Group).talk(session_id, nick, **opts)
def process(session_id, fields): usage = "Usage: whereis {-a} {nick}" if fields[0]: try: opts, nick = ltd.get_opts(fields[0], mode="a") if not nick: raise LtdErrorException(usage) except: raise LtdErrorException(usage) ACTION(actions.usersession.UserSession).whereis( session_id, nick, **opts, msgid=msgid(fields)) else: raise LtdErrorException(usage)
def __change_idle_boot__(self, moderator, info, minutes): old_val = info.idle_boot info.idle_boot = minutes self.broker.to_channel(info.key, ltd.encode_status_msg("Change", "%s changed idle-boot to %s." % (moderator, info.idle_boot_str))) if old_val > minutes and minutes > 0: boot_ids = [] for sub_id in self.broker.get_subscribers(str(info)): sub_state = self.session.get(sub_id) if (not info.moderator or sub_id != info.moderator): if sub_state.t_recv.elapsed() > (info.idle_boot * 60): boot_ids.append(sub_id) for sub_id in boot_ids: ACTION(actions.usersession.UserSession).idle_boot(sub_id)
def sign_off(self, session_id): state = self.session.get(session_id) if state.nick: self.log.debug("Dropping session: %s", session_id) if state.authenticated: with self.nickdb_connection.enter_scope() as scope: self.nickdb.set_signoff(scope, state.nick) scope.complete() ACTION(Notify).notify_signoff(session_id) if state.group: self.log.debug("Removing %s from channel %s.", state.nick, state.group) if self.broker.part(session_id, state.group): info = self.groups.get(state.group) if info.volume != group.Volume.QUIET and info.moderator != session_id: self.broker.to_channel_from( session_id, state.group, ltd.encode_status_msg( "Sign-off", "%s (%s) has signed off." % (state.nick, state.address))) else: self.groups.delete(state.group) self.drop_moderator(session_id, "Sign-off", "Your moderator signed off.") self.log.debug("Removing nick %s from session %s.", state.nick, session_id) self.session.update(session_id, nick=None, authenticated=False)
def process(session_id, fields): if not fields[0]: raise LtdErrorException("Usage: /boot {nick}") ACTION(actions.group.Group).boot(session_id, fields[0])
def process(session_id, fields): if fields[0]: ACTION(actions.group.Group).pass_over(session_id, fields[0]) else: ACTION(actions.group.Group).relinquish(session_id)
def process(session_id, fields): if not fields[0]: raise LtdErrorException("Usage: /wall {message}") ACTION(actions.admin.Admin).wall(session_id, fields[0])
def process(session_id, fields): if not fields[0]: raise LtdErrorException("Usage: /reputation {nick}") ACTION(actions.admin.Admin).get_reputation(session_id, fields[0], msgid(fields))
def process(session_id, fields): delay = int(fields[0]) if (fields[0] and fields[0].isdigit()) else 60 ACTION(actions.admin.Admin).shutdown(session_id, max(delay, 0), restart=True)
def process(session_id, fields): if fields[0]: raise LtdErrorException("Usage: /v") ACTION(actions.info.Info).version(session_id, msgid(fields))
def process(session_id, fields): argv = [s.strip() for s in fields[0].split(" ")] ACTION(actions.admin.Admin).ipfilter(session_id, argv)
def process(session_id, fields): if fields[0]: ACTION(actions.help.Help).query(session_id, fields[0], msgid(fields)) else: ACTION(actions.help.Help).introduction(session_id, msgid(fields))
def process(session_id, fields): ACTION(actions.admin.Admin).cancel_shutdown(session_id)