Exemplo n.º 1
0
def foo(message):
    if (message.text == '/start'):
        bot.send_message(
            message.chat.id,
            '*Ассалому алайкум! Мен расмдаги матнларни одий матнларга айлантира оламан!\nМенга тиниқ матнли расм юборинг!*',
            parse_mode='markdown')
        db.newuser(message.chat.id)
Exemplo n.º 2
0
def start(update, context):
    context.bot.send_message(
        chat_id=update.effective_chat.id,
        text=
        f"Hi {update.effective_chat.first_name}\n\n I can give you cool tweets just use commands you can use @twitterabot in any chat to send latest tweets or when you stay subscribed to the bot if there was anything I will send you stuff !!!"
    )
    db.newuser(update.effective_chat.first_name, update.effective_chat.id)
    print(f"hoooraaa new user {update.effective_chat.first_name}")
Exemplo n.º 3
0
def register():
	if request.method=="POST":
		button = request.form['button']
		if button == 'Register':
			username = request.form['username']
			password = request.form['password']
			email = request.form['email']
			cpassword = request.form['passwordconfirm']
			cemail = request.form['emailconfirm']
			first = request.form['firstname']
			last = request.form['lastname']
			idnum = request.form['idnumber']
			if email == cemail and password == cpassword and idnum.isdigit() and int(idnum) < 10000 and int(idnum) >= 0 and len(first) > 0 and len(last) > 0:
				if db.newuser(username, password, idnum, email, first, last) == True:
					session["username"] = str(username)
					session["itemsubmitted"] = False
					print session["username"]
					session["idnum"] = int(idnum)
					print session["idnum"]
					session["email"] = str(email)
					session["first"] = str(first)
					session["last"] = str(last)
					return redirect(url_for("userpage"))
					#return redirect(url_for("welcome",username, password, email, name, idnum))
				else:
					return render_template("register.html",exists = True, notloggedin = True)
			elif email != cemail or  password != cpassword:
				return render_template("register.html",mismatch = True, notloggedin = True)
			elif first == "" or last == "":
				return render_template("register.html",invname = True, notloggedin = True)
			else:
				return render_template("register.html",invid = True, notloggedin = True)
		elif button == "Login":
			username = request.form['username']
			password = request.form['password']
			du = (db.authuser(username, password))
			if du != False:
					session["username"] = str(username)
					u = du[1]
					session["idnum"] = int(u["idnum"])
					session["email"] = str(u["email"])
					session["first"] = str(u["first"])
					session["last"] = str(u["last"])
					print session["username"]
					print session["idnum"]
					print "u:" + u["first"]
					print "last: " + session["last"]
					print "name: " + session["first"]
					session["itemsubmitted"] = False
					return redirect(url_for("userpage"))
			else:
				return render_template("register.html",loginfailed = True, notloggedin = True)
		else:
			session["searchcat"] = [str(button)]
			return redirect(url_for("search"))
	else:
		if "username" in session:
			return render_template("register.html")	
		else:
			return render_template("register.html", notloggedin = True)
Exemplo n.º 4
0
            move = move.replace('shopkeeper', 'merchant')
            move = move.replace('apple paste', 'paste')
            move = move.replace(u'🌺', 'flower')
            move = move.replace(' an ', ' ')
            move = move.replace(' a ', ' ')

            # attempts to grab current user from users table
            user_exists = db.select('name', 'users', 'id', user['id'])
            if user_exists == None:
                if move == 'start':
                    db.log(rec, 'new player: ' + user['screen_name'])
                    position_init = 'start'
                    inventory_init = {}
                    events_init = {}
                    events_init[position_init] = {}
                    db.newuser(user['screen_name'], user['id'], user['tweet_id'], position_init, inventory_init, events_init)
                    reply = True
                else:
                    # this reply is purely for debugging - since reply defaults to True, this would be redundant
                    db.log(rec, user['screen_name'] + ' isn\'t playing Lilt.')
                    reply = False
            else:
                db.log(rec, 'current player: ' + user['screen_name'])
                tweet_exists = db.select('name', 'users', 'last_tweet_id', user['tweet_id'])
                if tweet_exists == None:
                    db.log(rec, 'new tweet')
                    if user['id'] != '724754312757272576':
                        db.update(user['tweet_id'], user['id'], 'last_tweet_id')
                    elif (user['id'] == '724754312757272576') and (builderid == False):
                        builderid = True
                        db.update(user['tweet_id'], user['id'], 'last_tweet_id')