コード例 #1
0
ファイル: message_command.py プロジェクト: gbtami/FatICS
    def run(self, args, conn):
        if conn.user.is_muted:
            conn.write(_('You are muted.\n'))
            return
        u2 = yield find_user.by_prefix_for_user(args[0], conn)
        # XXX maybe this check should be combined with the one in 'message'
        if u2:
            u2censor = yield u2.get_censor()
            if conn.user.name in u2censor and not conn.user.is_admin():
                conn.write(_('%s is censoring you.\n') % u2.name)
                return
            msgs = yield db.get_messages_range(conn.user.id_, args[1], args[1])
            if msgs:
                msg = msgs[0]
                message_id = msg['message_id']
                msg['forwarder_name'] = conn.user.name
                yield db.forward_message(conn.user.id_, u2.id_, message_id)
                msg_str_u2 = self._format_msg(msg,
                                              u2)  # localized for receiver

                if u2.vars_['mailmess']:
                    email.send_mail(conn.user, u2, msg_str_u2)
                    conn.write(
                        _('The following message was forwarded and emailed to %s:\n'
                          ) % u2.name)
                else:
                    conn.write(
                        _('The following message was forwarded to %s:\n') %
                        u2.name)
                if u2.is_online:
                    u2.write_('The following message was received:\n')
                    u2.write(msg_str_u2)
                self._write_msg(msg, conn.user)
            else:
                conn.write(_('There is no such message.\n'))
コード例 #2
0
ファイル: message_command.py プロジェクト: ecolitan/fatics
    def run(self, args, conn):
        if conn.user.is_muted:
            conn.write(_('You are muted.\n'))
            return
        u2 = user.find_by_prefix_for_user(args[0], conn)
        if u2:
            if conn.user.name in u2.censor and not conn.user.is_admin():
                conn.write(_('%s is censoring you.\n') % u2.name)
                return
            msgs = db.get_messages_range(conn.user.id, args[1], args[1])
            if msgs:
                msg = msgs[0]
                message_id = msg['message_id']
                msg['forwarder_name'] = conn.user.name
                db.forward_message(conn.user.id, u2.id, message_id)
                msg_str_u2 = self._format_msg(msg, u2) # localized for receiver

                if u2.vars['mailmess']:
                    email.send_mail(conn.user, u2, msg_str_u2)
                    conn.write(_('The following message was forwarded and emailed to %s:\n') % u2.name)
                else:
                    conn.write(_('The following message was forwarded to %s:\n') % u2.name)
                if u2.is_online:
                    u2.write_('The following message was received:\n')
                    u2.write(msg_str_u2)
                self._write_msg(msg, conn.user)
            else:
                conn.write(_('There is no such message.\n'))
コード例 #3
0
ファイル: message_command.py プロジェクト: pi4chess/fatics
    def run(self, args, conn):
        if conn.user.is_muted:
            conn.write(_('You are muted.\n'))
            return
        u2 = user.find_by_prefix_for_user(args[0], conn)
        if u2:
            if conn.user.name in u2.censor and not conn.user.is_admin():
                conn.write(_('%s is censoring you.\n') % u2.name)
                return
            msgs = db.get_messages_range(conn.user.id, args[1], args[1])
            if msgs:
                msg = msgs[0]
                message_id = msg['message_id']
                msg['forwarder_name'] = conn.user.name
                db.forward_message(conn.user.id, u2.id, message_id)
                msg_str_u2 = self._format_msg(msg,
                                              u2)  # localized for receiver

                if u2.vars['mailmess']:
                    email.send_mail(conn.user, u2, msg_str_u2)
                    conn.write(
                        _('The following message was forwarded and emailed to %s:\n'
                          ) % u2.name)
                else:
                    conn.write(
                        _('The following message was forwarded to %s:\n') %
                        u2.name)
                if u2.is_online:
                    u2.write_('The following message was received:\n')
                    u2.write(msg_str_u2)
                self._write_msg(msg, conn.user)
            else:
                conn.write(_('There is no such message.\n'))
コード例 #4
0
ファイル: root_handler.py プロジェクト: jhsi/tymdrop
 def sign_up(self, email, password):
     try:
         user_id = db.new_user(email=email, password=password)
         self.set_secure_cookie('user_id', user_id)
         mail.send_mail(
             recipients=[email],
             subject='Welcome to tymdrop!',
             content='Welcome to http://www.tymdrop.com')
     except IntegrityError:
         raise web.HTTPError(400, reason="That email address is already taken")
コード例 #5
0
ファイル: autoBuild.py プロジェクト: bingzhenqian/autoBuild
def emailSend(dic):
    email = EmailUtil(dic)
    email.send_mail()
コード例 #6
0
ファイル: message_command.py プロジェクト: gbtami/FatICS
    def run(self, args, conn):
        if args[0] is None:
            # display all messages
            msgs = yield db.get_messages_all(conn.user.id_)
            if not msgs:
                conn.write(_('You have no messages.\n'))
            else:
                conn.write(_('Messages:\n'))
                for msg in msgs:
                    conn.write(_('%d. ') % (msg['num']))
                    self._write_msg(msg, conn.user)
                yield db.set_messages_read_all(conn.user.id_)
        elif args[0] == 'u':
            if args[1] is not None:
                raise BadCommandError
            msgs = yield db.get_messages_unread(conn.user.id_)
            if not msgs:
                conn.write(_('You have no unread messages.\n'))
            else:
                conn.write(_('Unread messages:\n'))
                for msg in msgs:
                    conn.write(_('%d. ') % (msg['num']))
                    self._write_msg(msg, conn.user)
                yield db.set_messages_read_all(conn.user.id_)
        elif args[1] is None:
            # display some messages
            try:
                i = int(args[0])
                msgs = yield db.get_messages_range(conn.user.id_, i, i)
                if not msgs:
                    conn.write(_('There is no such message.\n'))
                    return
            except ValueError:
                m = self.range_re.match(args[0])
                if m:
                    (start, end) = (int(m.group(1)), int(m.group(2)))
                    # sanity checks
                    if start < 1 or start > end or end > 9999:
                        conn.write(_('Invalid message range.\n'))
                        return
                    msgs = yield db.get_messages_range(conn.user.id_, start,
                                                       end)
                else:
                    u2 = yield find_user.by_prefix_for_user(args[0], conn)
                    if not u2:
                        return
                    if u2.is_guest:
                        conn.write(
                            _('Only registered players can have messages.\n'))
                        return
                    msgs = yield db.get_messages_from_to(conn.user.id_, u2.id_)
                    if not msgs:
                        conn.write(
                            _('You have no messages to %s.\n') % u2.name)
                    else:
                        conn.write(_('Messages to %s:\n') % u2.name)
                        for msg in msgs:
                            self._write_msg(msg, conn.user)
                    conn.write('\n')

                    msgs = yield db.get_messages_from_to(u2.id_, conn.user.id_)
                    if not msgs:
                        conn.write(
                            _('You have no messages from %s.\n') % u2.name)
                        return
                    else:
                        conn.write(_('Messages from %s:\n') % u2.name)

            for msg in msgs:
                conn.write(_('%d. ') % (msg['num']))
                self._write_msg(msg, conn.user)
                if msg['unread']:
                    yield db.set_message_read(msg['message_id'])
        else:
            """ Send a message.  Note that the message may be localized
            differently for the sender and receiver. """
            to = yield find_user.by_prefix_for_user(args[0], conn)
            if to:
                if conn.user.is_muted:
                    conn.write(_('You are muted.\n'))
                    return
                if to.is_guest:
                    conn.write(
                        _('Only registered players can have messages.\n'))
                    return
                tocensor = yield to.get_censor()
                if conn.user.name in tocensor and not conn.user.is_admin():
                    conn.write(_('%s is censoring you.\n') % to.name)
                    return
                message_id = yield db.send_message(conn.user.id_, to.id_,
                                                   args[1])
                msg = yield db.get_message(message_id)
                msg_str_to = self._format_msg(msg,
                                              to)  # localized for receiver

                if to.vars_['mailmess']:
                    email.send_mail(conn.user, to, msg_str_to)
                    conn.write(
                        _('The following message was sent and emailed to %s:\n'
                          ) % to.name)
                else:
                    conn.write(
                        _('The following message was sent to %s:\n') % to.name)
                self._write_msg(msg, conn.user)

                if to.is_online:
                    to.write_('The following message was received:\n')
                    to.write(msg_str_to)
コード例 #7
0
ファイル: message_command.py プロジェクト: ecolitan/fatics
    def run(self, args, conn):
        if args[0] is None:
            # display all messages
            msgs = db.get_messages_all(conn.user.id)
            if not msgs:
                conn.write(_('You have no messages.\n'))
            else:
                conn.write(_('Messages:\n'))
                for msg in msgs:
                    conn.write(_('%d. ') % (msg['num']))
                    self._write_msg(msg, conn.user)
                db.set_messages_read_all(conn.user.id)
        elif args[0] == 'u':
            if args[1] is not None:
                raise BadCommandError
            msgs = db.get_messages_unread(conn.user.id)
            if not msgs:
                conn.write(_('You have no unread messages.\n'))
            else:
                conn.write(_('Unread messages:\n'))
                for msg in msgs:
                    conn.write(_('%d. ') % (msg['num']))
                    self._write_msg(msg, conn.user)
                db.set_messages_read_all(conn.user.id)
        elif args[1] is None:
            # display some messages
            if type(args[0]) == type(1):
                i = int(args[0])
                msgs = db.get_messages_range(conn.user.id, i, i)
                if not msgs:
                    conn.write(_('There is no such message.\n'))
                    return
            else:
                m = self.range_re.match(args[0])
                if m:
                    (start, end) = (int(m.group(1)), int(m.group(2)))
                    # sanity checks
                    if start < 1 or start > end or end > 9999:
                        conn.write(_('Invalid message range.\n'))
                        return
                    msgs = db.get_messages_range(conn.user.id, start, end)
                else:
                    u2 = user.find_by_prefix_for_user(args[0], conn)
                    if not u2:
                        return
                    msgs = db.get_messages_from_to(conn.user.id, u2.id)
                    if not msgs:
                        conn.write(_('You have no messages to %s.\n') % u2.name)
                    else:
                        conn.write(_('Messages to %s:\n') % u2.name)
                        for msg in msgs:
                            self._write_msg(msg, conn.user)
                    conn.write('\n')

                    msgs = db.get_messages_from_to(u2.id, conn.user.id)
                    if not msgs:
                        conn.write(_('You have no messages from %s.\n') % u2.name)
                        return
                    else:
                        conn.write(_('Messages from %s:\n') % u2.name)

            for msg in msgs:
                conn.write(_('%d. ') % (msg['num']))
                self._write_msg(msg, conn.user)
                if msg['unread']:
                    db.set_message_read(msg['message_id'])
        else:
            """ Send a message.  Note that the message may be localized
            differently for the sender and receiver. """
            to = user.find_by_prefix_for_user(args[0], conn)
            if to:
                if conn.user.is_muted:
                    conn.write(_('You are muted.\n'))
                    return
                if to.is_guest:
                    conn.write(_('Only registered players can have messages.\n'))
                    return
                if conn.user.name in to.censor and not conn.user.is_admin():
                    conn.write(_('%s is censoring you.\n') % to.name)
                    return
                message_id = db.send_message(conn.user.id, to.id, args[1])
                msg = db.get_message(message_id)
                msg_str_to = self._format_msg(msg, to) # localized for receiver

                if to.vars['mailmess']:
                    email.send_mail(conn.user, to, msg_str_to)
                    conn.write(_('The following message was sent and emailed to %s:\n') %
                        to.name)
                else:
                    conn.write(_('The following message was sent to %s:\n') %
                        to.name)
                self._write_msg(msg, conn.user)

                if to.is_online:
                    to.write_('The following message was received:\n')
                    to.write(msg_str_to)