def POST(self, user_id): user = users.get_current_user() if user: d = web.input() f = contact_form(message=d.message) if f.validate() and util.user_exists(user_id.lower()): taskqueue.add( url="/task/send_mail", queue_name="email-throttle", params={"sender_id": user.user_id(), "recipient_id": user_id, "message": f.message.data}, ) raise web.seeother("/" + user_id + "#message_sent") elif f.validate() and user_id.lower() == "us": taskqueue.add( url="/task/send_mail", queue_name="email-throttle", params={"sender_id": user.user_id(), "recipient_id": "us", "message": f.message.data}, ) raise web.seeother("/" + user_id + "#message_sent") else: return t.render( util.data( title="Get in touch!", instructions="""You will always reveal your email address when you send a message!""", form=f, subject=" ".join([user.nickname(), "wants to get in touch!"]), ) ) else: return t.render(util.data(title="Not allowed!", instructions="You must be signed in to send messages!"))
async def on_voice_state_update(self, member, before, after): c = after.channel or before.channel opts = (self.conn, member.id, c.guild.id) if not before.channel and after.channel: # when joining a channel, not switching if not util.user_exists(opts): util.user_add(opts) if not util.user_has_joined_today(opts): util.give_streak(opts) await util.user_update_nickname(self.conn, self.bot, self.icons, member, c.guild.id) util.user_update_last_joined(opts)
class RegistrationForm(FlaskForm): """ Fields and validation for User Registration """ username = StringField( 'Username', validators=[DataRequired(), Length(min=3, max=32), user_exists()]) name = StringField('Full Name', validators=[DataRequired(), Length(min=2)]) display_name = StringField( 'Display Name', validators=[DataRequired(), Length(min=2, max=32)]) email = StringField('Email', validators=[DataRequired(), Email()])
async def on_voice_state_update(self, member, before, after): if not before.channel and after.channel: if not util.user_exists(self.conn, member.id, after.channel.guild.id): util.user_add(self.conn, member.id, after.channel.guild.id) if not util.user_has_joined_today(self.conn, member.id, after.channel.guild.id): util.give_streak(self.conn, member.id, after.channel.guild.id) await util.user_update_nickname(self.conn, self.bot, self.icons, member, after.channel.guild.id) util.user_update_last_joined(self.conn, member.id, after.channel.guild.id)
def GET(self, user_id): if util.user_exists(user_id.lower()) or user_id.lower() == "us": t = template.env.get_template("contact.html") f = contact_form() user = users.get_current_user() if user: return t.render( util.data( title="Get in touch!", instructions="""You will always reveal your email address when you send a message!""", form=f, subject=" ".join([user.nickname(), "wants to get in touch!"]), ) ) else: return t.render(util.data(title="Not allowed!", instructions="You must be signed in to send messages!")) else: raise web.notfound()
class LoginForm(FlaskForm): """ Fields and validation for User Login """ username = StringField( 'Username', validators=[DataRequired(), user_exists(for_login=True)])