forked from ilmanhdyt/ShiraoriBOT-Md
-
Notifications
You must be signed in to change notification settings - Fork 4
/
_firstchat.js
42 lines (38 loc) · 1.58 KB
/
_firstchat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
let moment = require('moment-timezone')
let handler = m => m
handler.before = async function (m) {
if (m.chat.endsWith('broadcast')) return
if (m.fromMe) return
if (m.isGroup) return
// if (db.data.settings.groupOnly) return
let user = global.db.data.users[m.sender]
let { banned } = db.data.users[m.chat]
let username = conn.getName(m.sender)
if (new Date - user.pc < 86400000) return // setiap 24 jam sekali
// await conn.modifyChat(m.chat, 'mute', -Math.floor(new Date / 1e3) * 1e3 - 1e3).catch(console.log)
await this.sendButton(m.chat, `
Hai ${ucapan()} *${username.replace(/@.+/, '')}* 👋
Saya adalah Botchat WhatsApp yang berkerja dengan menggunakan bahasa javascript.
${banned ? 'kamu *terbanned* kak 😕\nHubungi: wa.me/6283106733687' : 'Ada yang bisa saya bantu?'}
`.trim(), wm, null, [['Menu', '/menu']], m)
user.pc = new Date * 1
}
module.exports = handler
function ucapan() {
const hour_now = moment.tz('Asia/Jakarta').format('HH')
var ucapanWaktu = 'Pagi kak'
if (hour_now >= '03' && hour_now <= '10') {
ucapanWaktu = 'Pagi kak'
} else if (hour_now >= '10' && hour_now <= '15') {
ucapanWaktu = 'Siang kak'
} else if (hour_now >= '15' && hour_now <= '17') {
ucapanWaktu = 'Sore kak'
} else if (hour_now >= '17' && hour_now <= '18') {
ucapanWaktu = 'Selamat Petang kak'
} else if (hour_now >= '18' && hour_now <= '23') {
ucapanWaktu = 'Malam kak'
} else {
ucapanWaktu = 'Selamat Malam!'
}
return ucapanWaktu
}