Skip to content

Commit

Permalink
WhatsAsena: Hata düzeltmeleri
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufusta committed Nov 23, 2020
1 parent 6345b6e commit 76ffdff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"REMOVE_BG_API_KEY": {
"description": "Fotoğrafların arkaplanını kaldırır.",
"required": false
},
"NO_ONLINE": {
"description": "Çevrimiçi görünmek istemiyorsanız true yazın.",
"required": false,
"value": "true"
}
},
"addons": [{
Expand Down
22 changes: 19 additions & 3 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const path = require("path");
const events = require("./events");
const chalk = require('chalk');
const config = require('./config');
const {WAConnection, MessageType, Mimetype} = require('@adiwajshing/baileys');
const {WAConnection, MessageType, Mimetype, Presence} = require('@adiwajshing/baileys');
const {Message, StringSession, Image, Video} = require('./whatsasena/');
const { DataTypes } = require('sequelize');
const { GreetingsDB, getMessage } = require("./plugins/sql/greetings");
Expand Down Expand Up @@ -46,8 +46,10 @@ async function whatsAsena () {
const Session = new StringSession();

conn.logger.level = 'warn';
var nodb;

if (StrSes_Db.length < 1) {
nodb = true;
conn.loadAuthInfo(Session.deCrypt(config.SESSION));
} else {
conn.loadAuthInfo(Session.deCrypt(StrSes_Db[0].dataValues.value));
Expand Down Expand Up @@ -95,6 +97,12 @@ ${chalk.blue.italic('ℹ️ WhatsApp\'a bağlanılıyor... Lütfen bekleyin.')}
});

conn.on('message-new', async msg => {
if (msg.key && msg.key.remoteJid == 'status@broadcast') return;

if (config.NO_ONLINE) {
await conn.updatePresence(msg.key.remoteJid, Presence.unavailable);
}

if (msg.messageStubType === 32 || msg.messageStubType === 28) {
// Görüşürüz Mesajı
var gb = await getMessage(msg.key.remoteJid, 'goodbye');
Expand Down Expand Up @@ -148,7 +156,7 @@ ${chalk.blue.italic('ℹ️ WhatsApp\'a bağlanılıyor... Lütfen bekleyin.')}
if (config.SEND_READ && command.on === undefined) {
await conn.chatRead(msg.key.remoteJid);
}

var match = text_msg.match(command.pattern);

if (command.on !== undefined && (command.on === 'image' || command.on === 'photo' )
Expand Down Expand Up @@ -182,7 +190,15 @@ ${chalk.blue.italic('ℹ️ WhatsApp\'a bağlanılıyor... Lütfen bekleyin.')}
)
});

await conn.connect();
try {
await conn.connect();
} catch {
if (!nodb) {
console.log(chalk.red.bold('Eski sürüm stringiniz yenileniyor...'))
conn.loadAuthInfo(Session.deCrypt(config.SESSION));
await conn.connect();
}
}
}

whatsAsena();
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DATABASE_URL = process.env.DATABASE_URL === undefined ? './whatsasena.db' : proc
DEBUG = process.env.DEBUG === undefined ? false : convertToBool(process.env.DEBUG);

module.exports = {
VERSION: 'v0.7.1 Public Beta',
VERSION: 'v0.7.2 Public Beta',
SESSION: process.env.ASENA_SESSION === undefined ? '' : process.env.ASENA_SESSION,
LANG: process.env.LANGUAGE === undefined ? 'tr' : process.env.LANGUAGE,
HANDLERS: process.env.HANDLERS === undefined ? '^[.!;]' : process.env.HANDLERS,
Expand All @@ -33,4 +33,5 @@ module.exports = {
DATABASE_URL: DATABASE_URL,
DATABASE: DATABASE_URL === './whatsasena.db' ? new Sequelize({ dialect: "sqlite", storage: DATABASE_URL, logging: DEBUG}) : new Sequelize(DATABASE_URL, {logging: DEBUG}),
RBG_API_KEY: process.env.REMOVE_BG_API_KEY === undefined ? false : process.env.REMOVE_BG_API_KEY,
NO_ONLINE: process.env.NO_ONLINE === undefined ? true : convertToBool(process.env.NO_ONLINE)
};
2 changes: 1 addition & 1 deletion plugins/afk.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Asena.addCommand({on: 'text', fromMe: false, deleteCommand: false}, (async (mess
}));

Asena.addCommand({on: 'text', fromMe: true, deleteCommand: false}, (async (message, match) => {
if (AFK.isAfk && !message.message.includes('Artık AFK\'yım!') && !message.message.includes('Bip bop! Bu bir bot. Sahibim şu an burada değil.')) {
if (AFK.isAfk && !message.message.includes('Artık AFK\'yım!') && !message.message.includes('Bip bop! Bu bir bot. Sahibim şu an burada değil.') && !message.message.includes('*-- HATA RAPORU [WHATSASENA] --*')) {
AFK.lastseen = 0;
AFK.reason = false;
AFK.isAfk = false;
Expand Down
2 changes: 1 addition & 1 deletion plugins/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Asena.addCommand({on: 'text', fromMe: false}, (async (message, match) => {
if (!filtreler) return;
filtreler.map(
async (filter) => {
pattern = new RegExp(filter.dataValues.regex ? filter.dataValues.pattern : '\\b' + filter.dataValues.pattern, 'g');
pattern = new RegExp(filter.dataValues.regex ? filter.dataValues.pattern : ('\\b' + filter.dataValues.pattern), 'g');
if (pattern.test(message.message)) {
await message.reply(filter.dataValues.text);
}
Expand Down

0 comments on commit 76ffdff

Please sign in to comment.