File size: 3,306 Bytes
bb69f9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const {
  bot,
  getName,
  formatTime,
  jidToNum,
  getGids,
  parsedJid,
  isUser,
  isGroup,
} = require('../lib/')
const fm = true

bot(
  {
    pattern: 'jid',
    desc: 'Give jid of chat/user',
    type: 'user',
  },
  async (message, match) => {
    return await message.send(message.mention[0] || message.reply_message.jid || message.jid)
  }
)

bot(
  {
    pattern: 'left',
    dec: 'To leave from group',
    type: 'user',
    onlyGroup: true,
  },
  async (message, match) => {
    if (match) await message.send(match)
    return await message.leftFromGroup(message.jid)
  }
)

bot(
  {
    pattern: 'block',
    desc: 'Block a person',
    type: 'user',
  },
  async (message, match) => {
    const id = message.mention[0] || message.reply_message.jid || (!message.isGroup && message.jid)
    if (!id) return await message.send('*Give me a person*')
    await message.send('_Blocked_')
    await message.Block(id)
  }
)

bot(
  {
    pattern: 'unblock',
    desc: 'Unblock a person',
    type: 'user',
  },
  async (message, match) => {
    const id = message.mention[0] || message.reply_message.jid || (!message.isGroup && message.jid)
    if (!id) return await message.send('*Give me a person*')
    await message.send('_Unblocked_')
    await message.Unblock(id)
  }
)

bot(
  {
    pattern: 'pp',
    desc: 'Change Profile Picture',
    type: 'user',
  },
  async (message, match) => {
    if (!message.reply_message || !message.reply_message.image)
      return await message.send('*Reply to a image*')
    await message.updateProfilePicture(await message.reply_message.downloadMediaMessage())
    return await message.send('_Profile Picture Updated_')
  }
)

bot(
  {
    pattern: 'whois ?(.*)',
    desc: 'To get PP and about',
    type: 'misc',
  },
  async (message, match) => {
    match = parsedJid(match)[0]
    const gid = (isGroup(match) && match) || message.jid
    const id = (isUser(match) && match) || message.mention[0] || message.reply_message.jid
    let pp = ''
    try {
      pp = await message.profilePictureUrl(id || gid)
    } catch (error) {
      // pp = 'https://cdn.wallpapersafari.com/0/83/zKyWb6.jpeg'
    }
    let caption = ''
    if (id) {
      caption = `*Num :* +${jidToNum(id)}`
      try {
        const [res] = await message.fetchStatus(id)
        if (res.status) {
          caption += `\n*Name :* ${await getName(gid, id, message.id)}\n*About :* ${
            res.status
          }\n*setAt :* ${res.date}`
        }
      } catch (error) {}
    } else {
      const { subject, size, creation, desc, owner } = await message.groupMetadata(gid, !!gid)
      caption = `*Name :* ${subject}\n*Owner :* ${owner ? '+' : ''}${jidToNum(
        owner
      )}\n*Members :* ${size}\n*Created :* ${formatTime(creation)}\n*Desc :* ${desc}`
    }
    if (!pp) return await message.send(caption, { quoted: message.data })
    return await message.sendFromUrl(pp, { caption, quoted: message.data })
  }
)

bot(
  {
    pattern: 'gjid',
    desc: 'List group jids',
    type: 'user',
  },
  async (message, match) => {
    const gids = await message.getGids()
    let msg = ''
    let i = 1
    for (const gid in gids) {
      const name = gids[gid].subject
      msg += `*${i}.* *${name} :* ${gid}\n\n`
      i++
    }
    await message.send(msg.trim())
  }
)