Beispiel #1
0
def league(league):
    user_team = request.params.get("team")
    if not user_team:
        # a malformed POST - didn't select a team.
        return redirect('/%s' % league)

    user_team = strip_tags(user_team)
    new_user(user_team.decode('utf-8'), conn)
    response.set_cookie(league, cookie_safe(user_team),
                        max_age=3600*24*365, path='/%s' % league)
    redirect('/%s' % league)
Beispiel #2
0
Datei: urls.py Projekt: vu-au/nmt
def league(league):
    user_team = request.params.get("team")
    if not user_team:
        # a malformed POST - didn't select a team.
        return redirect('/%s' % league)

    user_team = strip_tags(user_team)
    new_user(user_team.decode('utf-8'), conn)
    response.set_cookie(league,
                        cookie_safe(user_team),
                        max_age=3600 * 24 * 365,
                        path='/%s' % league)
    redirect('/%s' % league)
Beispiel #3
0
async def start(message):
    """
    Sends a help message
    """
    chat_id = message.chat.id

    user = models.get_user(chat_id)
    if user is None:
        models.new_user(message)

    reply_keys = types.ReplyKeyboardMarkup(resize_keyboard=True)
    get_cat = types.KeyboardButton(text='Кота мне!')
    get_help = types.KeyboardButton(text='Помощь')
    how_to_add = types.KeyboardButton('Добавить кота')

    reply_keys.row(get_cat)
    reply_keys.row(get_help, how_to_add)

    await bot.send_message(chat_id, 'Просто тыкай на кнопку и наслаждайся🐈)',
                           reply_markup=reply_keys)
Beispiel #4
0
    def post(self):
        nickname = self.get_argument("nickname")
        password1 = self.get_argument("password1")
        password2 = self.get_argument("password2")
        email = self.get_argument("email")

        self.set_current_nickname(nickname)

        if (password1 != password2):
            self.write(
                "<html><body><script type=\"text/JavaScript\">alert(\"passwords are different\"); window.history.back()</script></html>"
            )

        a = [0]
        while (len(a) != 0):
            id = random.randint(100000, 999999)
            a = db.select("select * from UserTable where ID = ?", id)

        if (new_user(id, password1, nickname, email)):
            self.render("rsuccess.html", id=id, rr_nickname=nickname)
        else:
            self.write(
                "<html><body><script type=\"text/JavaScript\">alert(\"E-mail format is incorrect\"); window.history.back()</script></html>"
            )
Beispiel #5
0
async def give_cat(message):
    """
    Sends a cat
    """
    chat_id = message.chat.id

    user = models.get_user(chat_id)
    if user is None:
        user = models.new_user(message)

    response = requests.get(cats_url).json()[0]
    photo = response['url']
    image_id = response['id']

    markup = types.InlineKeyboardMarkup(row_width=2)

    vote_up_button = types.InlineKeyboardButton(
        '👍',
        callback_data=f'up{image_id}')
    vote_down_button = types.InlineKeyboardButton(
        '👎',
        callback_data=f'down{image_id}')

    send_photo = types.InlineKeyboardButton('Отправить всем пользователям!',
                                            callback_data=f'send{photo}')

    markup.row(vote_up_button, vote_down_button)
    markup.add(send_photo)

    await bot.send_photo(chat_id=chat_id, photo=photo,
                         reply_markup=markup)

    user.messages = int(user.messages) + 1 if user.messages is not None \
        else 1
    models.session.add(user)
    models.session.commit()
Beispiel #6
0
def user_reg(user_id):
    user = models.get_user_tg(user_id)
    if not user:
        user = models.new_user(user_id)