p
Size: a a a
p
YZ
YZ
YZ
p
Sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
YZ
p
User
.findOne({where: {user_id: context.senderId}, fields: ['id', 'user_id', 'sex', 'companion', 'conversation', 'last_conversation', 'last_companion', 'status', 'finding', 'last_finding', 'warns', 'last_warn', 'is_banned', 'is_banned_perm', 'bandate']})
.then(async (user) => {
if(!user)
{
vk.api.users.get({
user_ids: context.senderId,
fields: "sex"
})
.then(response => {
let sex = response[0].sex;
User
.create({user_id: context.senderId, status: 0, finding: 0, sex: sex})
.then((newuser) => {
context.user = newuser;
if(context.state.command !== "start")
{
context.state.command = 'start';
}
return next();
})
})
.catch((error) => { console.error(error); });
}
YZ
p
p
p
YZ
p
p
vk.updates.on('message', (context, next) => {YZ
p
p
YZ
YZ