Skip to content

Commit

Permalink
WhatsAsena: Bug fixes & weather command
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufusta committed Nov 24, 2020
1 parent 8ac709f commit 89eeeb9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
6 changes: 5 additions & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ ${chalk.blue.italic('ℹ️ WhatsApp\'a bağlanılıyor... Lütfen bekleyin.')}
if (!nodb) {
console.log(chalk.red.bold('Eski sürüm stringiniz yenileniyor...'))
conn.loadAuthInfo(Session.deCrypt(config.SESSION));
await conn.connect();
try {
await conn.connect();
} catch {
return;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/scrapers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Asena.addCommand({pattern: 'song ?(.*)', fromMe: true, desc: 'Yazdığınız şa
let arama = await yts(match[1]);
arama = arama.all;
if(arama.length < 1) return await message.sendMessage('*Hiçbir şey bulamadım :(*\n');
var reply = await message.reply('```Şarkınız indiriliyor...```');
var reply = await message.sendMessage('```Şarkınız indiriliyor...```');

let title = arama[0].title.replace(' ', '+');
let stream = ytdl(arama[0].videoId, {
Expand Down
2 changes: 1 addition & 1 deletion plugins/stickers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const cwebp = require('cwebp-bin');

Asena.addCommand({pattern: 'sticker', fromMe: true, desc: 'Yanıt verdiğiniz fotoğraf veya videoyu sticker yapın.'}, (async (message, match) => {
if (message.reply_message === false) return await message.sendMessage('*Bir fotoğraf veya videoya yanıt verin!*');
var info = await message.reply('```Medya indiriliyor & sticker yapılıyor...```');
var info = await message.sendMessage('```Medya indiriliyor & sticker yapılıyor...```');

var location = await message.client.downloadAndSaveMediaMessage({
key: {
Expand Down
2 changes: 1 addition & 1 deletion plugins/system_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Asena.addCommand({pattern: 'alive', fromMe: true, desc: 'Bot çalışıyor mu?'}
Asena.addCommand({pattern: 'sysd', fromMe: true, desc: 'Sistem özelliklerini söyler.'}, (async (message, match) => {
const child = spawnSync('neofetch', ['--stdout']).stdout.toString('utf-8')
await message.sendMessage(
child, MessageType.text
'```' + child + '```', MessageType.text
);
}));
34 changes: 34 additions & 0 deletions plugins/weather.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Copyright (C) 2020 Yusuf Usta.
Licensed under the GPL-3.0 License;
you may not use this file except in compliance with the License.
WhatsAsena - Yusuf Usta
*/

const Asena = require('../events');
const {MessageType} = require('@adiwajshing/baileys');
const got = require('got');

Asena.addCommand({pattern: 'weather ?(.*)', desc: 'Hava durumu getirir.', usage: '.weather Bakü'}, async (message, match) => {
if (match[1] === '') return await message.reply('*Lütfen bir konum yazın!*\n*Örnek:* ```.weather Bakü```');
const url = `http://api.openweathermap.org/data/2.5/weather?q=${match[1]}&units=metric&appid=060a6bcfa19809c2cd4d97a212b19273&language=tr`;
try {
const response = await got(url);
} catch {
return await message.reply('```Böyle bir şehir bulamadım. 😖```');
}

const json = JSON.parse(response.body);

if (response.statusCode === 200) {
return await message.reply('*📍 Konum:* ```' + match[1] + '```\n\n' +
'*☀ Sıcaklık:* ```' + json.main.temp_max + '°```\n' +
'*ℹ Açıklama:* ```' + json.weather[0].description + '```\n' +
'*☀ Nem:* ```%' + json.main.humidity + '```\n' +
'*💨 Rüzgar Hızı:* ```' + json.wind.speed + 'm/s```\n' +
'*☁ Bulut:* ```%' + json.clouds.all + '```\n');
} else {
return await message.reply('```Böyle bir şehir bulamadım. 😖```');
}
});
2 changes: 1 addition & 1 deletion whatsasena/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Message extends Base {
}

async reply(text) {
var message = await this.client.sendMessage(this.jid, text, MessageType.text, {quoted: this.data})
var message = await this.client.sendMessage(this.jid, text, MessageType.text);
return new Message(this.client, message)
}

Expand Down

0 comments on commit 89eeeb9

Please sign in to comment.