File size: 1,959 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
const {
  bot,
  // genButtonMessage,
  mentionMessage,
  enableMention,
  clearFiles,
  getMention,
} = require('../lib/')

bot(
  {
    pattern: 'mention ?(.*)',
    desc: 'To set and Manage mention',
    type: 'misc',
  },
  async (message, match) => {
    if (!match) {
      const mention = await getMention(message.id)
      const onOrOff = mention && mention.enabled ? 'on' : 'off'
      return await message.send(
        `Mention is ${onOrOff}\n\nhttps://levanter-plugins.vercel.app/faq`
      )

      // const button = await genButtonMessage(
      // 	[
      // 		{ id: 'mention get', text: 'GET' },
      // 		{ id: `mention ${onOrOff}`, text: onOrOff.toUpperCase() },
      // 	],
      // 	'Example\nhttps://github.com/lyfe00011//whatsapp-bot-md/wiki/mention_example',
      // 	'Mention'
      // )
      // return await message.send(button, {}, 'button')
      // return await message.send(
      // 	await genHydratedButtons(
      // 		[
      // 			{
      // 				urlButton: {
      // 					text: 'example',
      // 					url: 'https://github.com/lyfe00011//whatsapp-bot-md/wiki/mention_example',
      // 				},
      // 			},
      // 			{ button: { id: 'mention on', text: 'ON' } },
      // 			{ button: { id: 'mention off', text: 'OFF' } },
      // 			{ button: { id: 'mention get', text: 'GET' } },
      // 		],
      // 		'Mention Msg Manager'
      // 	),
      // 	{},
      // 	'template'
      // )
    }
    if (match == 'get') {
      const msg = await mentionMessage(message.id)
      if (!msg) return await message.send('_Reply to Mention not Activated._')
      return await message.send(msg)
    } else if (match == 'on' || match == 'off') {
      await enableMention(match == 'on', message.id)
      return await message.send(`_Reply to mention ${match == 'on' ? 'Activated' : 'Deactivated'}_`)
    }
    await enableMention(match, message.id)
    clearFiles()
    return await message.send('_Mention Updated_')
  }
)