@@ -667,103 +667,94 @@ if (m.fromMe && (global.db.data.settings[this.user.jid]?.ownerreacts)) {
667
667
668
668
/**
669
669
* Handle groups participants update
670
- * @param {import('@whiskeysockets /baileys').BaileysEventMap<unknown>['group-participants.update'] } groupsUpdate
670
+ * @param {import('@adiwajshing /baileys').BaileysEventMap<unknown>['group-participants.update'] } groupsUpdate
671
671
*/
672
672
export async function participantsUpdate ( { id, participants, action } ) {
673
- if ( opts [ 'self' ] )
674
- return
675
- // if (id in conn.chats) return // First login will spam
676
- /*if (this.isInit)
677
- return*/
678
- if ( global . db . data == null )
679
- await loadDatabase ( )
680
- let chat = global . db . data . chats [ id ] || { }
681
- let text = ''
682
- switch ( action ) {
683
- case 'add' :
684
- case 'remove' :
685
- if ( chat . welcome ) {
686
- let groupMetadata = await this . groupMetadata ( id ) || ( conn . chats [ id ] || { } ) . metadata
687
- for ( let user of participants ) {
688
- let pp = 'https://i.ibb.co/1ZxrXKJ/avatar-contact.jpg'
689
- let ppgp = 'https://i.ibb.co/1ZxrXKJ/avatar-contact.jpg'
690
- try {
691
- pp = await this . profilePictureUrl ( user , 'image' )
692
- ppgp = await this . profilePictureUrl ( id , 'image' )
693
- } finally {
694
- text = ( action === 'add' ? ( chat . sWelcome || this . welcome || conn . welcome || 'Welcome, @user' ) . replace ( '@group' , await this . getName ( id ) ) . replace ( '@desc' , groupMetadata . desc ?. toString ( ) || 'Unknown' ) :
695
- ( chat . sBye || this . bye || conn . bye || 'Goodbye, @user' ) ) . replace ( '@user' , '@' + user . split ( '@' ) [ 0 ] )
696
-
697
- let wel = API ( 'fgmods' , '/api/welcome' , {
698
- username : await this . getName ( user ) ,
699
- groupname : await this . getName ( id ) ,
700
- groupicon : ppgp ,
701
- membercount : groupMetadata . participants . length ,
702
- profile : pp ,
703
- background : 'https://qu.ax/GHTLH.jpg'
704
- } , 'apikey' )
705
-
706
- let lea = API ( 'fgmods' , '/api/goodbye2' , {
707
- username : await this . getName ( user ) ,
708
- groupname : await this . getName ( id ) ,
709
- groupicon : ppgp ,
710
- membercount : groupMetadata . participants . length ,
711
- profile : pp ,
712
- background : 'https://qu.ax/BOszQ.jpg'
713
- } , 'apikey' )
714
-
715
- this . sendFile ( id , action === 'add' ? wel : lea , 'pp.jpg' , text , null , false , { mentions : [ user ] } )
716
- //this.sendFile(id, pp, 'pp.jpg', text, null, false, { mentions: [user] })
717
- /*this.sendButton(id, text, mssg.ig, action === 'add' ? wel : lea, [
718
- [(action == 'add' ? '⦙☰ MENU' : 'BYE'), (action == 'add' ? '/help' : 'khajs')],
719
- [(action == 'add' ? '⏍ RULES' : 'ッ'), (action == 'add' ? '/rules' : ' ')] ], null, {mentions: [user]})*/
720
-
721
- }
722
- }
723
- }
724
- break
725
- case 'promote' :
726
- text = ( chat . sPromote || this . spromote || conn . spromote || '@user is now an administrator' )
727
- case 'demote' :
728
- let pp = await this . profilePictureUrl ( participants [ 0 ] , 'image' ) . catch ( _ => 'https://i.ibb.co/1ZxrXKJ/avatar-contact.jpg' )
729
- if ( ! text )
730
- text = ( chat . sDemote || this . sdemote || conn . sdemote || '@user is no longer an administrator' )
731
- text = text . replace ( '@user' , '@' + participants [ 0 ] . split ( '@' ) [ 0 ] )
732
- if ( chat . detect )
733
- this . sendFile ( id , pp , 'pp.jpg' , text , null , false , { mentions : this . parseMention ( text ) } )
734
- break
735
- }
736
- }
673
+ if ( opts [ 'self' ] )
674
+ return
675
+ // if (id in conn.chats) return // First login will spam
676
+ if ( this . isInit )
677
+ return
678
+ if ( global . db . data == null )
679
+ await loadDatabase ( )
680
+ let chat = global . db . data . chats [ id ] || { }
681
+ let text = ''
682
+ switch ( action ) {
683
+ case 'add' :
684
+ case 'remove' :
685
+ if ( chat . welcome ) {
686
+ let groupMetadata = await this . groupMetadata ( id ) || ( conn . chats [ id ] || { } ) . metadata
687
+ for ( let user of participants ) {
688
+ let pp = global . gataImg
689
+ try {
690
+ pp = await this . profilePictureUrl ( user , 'image' )
691
+ } catch ( e ) {
692
+ } finally {
693
+ let apii = await this . getFile ( pp )
694
+ const botTt2 = groupMetadata . participants . find ( u => this . decodeJid ( u . id ) == this . user . jid ) || { }
695
+ const isBotAdminNn = botTt2 ?. admin === "admin" || false
696
+ text = ( action === 'add' ? ( chat . sWelcome || this . welcome || conn . welcome || 'Welcome, @user!' ) . replace ( '@subject' , await this . getName ( id ) ) . replace ( '@desc' , groupMetadata . desc ?. toString ( ) || '😻 𝗦𝘂𝗽𝗲𝗿 𝗚𝗮𝘁𝗮𝗕𝗼𝘁-𝗠𝗗 😻' ) :
697
+ ( chat . sBye || this . bye || conn . bye || 'Bye, @user!' ) ) . replace ( '@user' , '@' + user . split ( '@' ) [ 0 ] )
698
+
737
699
700
+
701
+ let fkontak2 = { "key" :
{ "participants" :
"[email protected] " , "remoteJid" :
"status@broadcast" , "fromMe" :
false , "id" :
"Halo" } , "message" :
{ "contactMessage" :
{ "vcard" :
`BEGIN:VCARD\nVERSION:3.0\nN:Sy;Bot;;;\nFN:y\nitem1.TEL;waid=${ user . split ( '@' ) [ 0 ] } :${ user . split ( '@' ) [ 0 ] } \nitem1.X-ABLabel:Ponsel\nEND:VCARD` } } , "participant" :
"[email protected] " }
702
+ this . sendMessage ( id , { text : text ,
703
+ contextInfo :{
704
+ forwardingScore : 9999999 ,
705
+ isForwarded : true ,
706
+ mentionedJid :[ user ] ,
707
+ "externalAdReply" : {
708
+ "showAdAttribution" : true ,
709
+ "renderLargerThumbnail" : true ,
710
+ "thumbnail" : apii . data ,
711
+ "title" : 'Prince♥️' ,
712
+ "containsAutoReply" : true ,
713
+ "mediaType" : 1 ,
714
+ sourceUrl : 'https://github.com/DASTAGHIR/PRINCEAI' } } } , { quoted : fkontak2 } )
715
+ apii . data = ''
716
+ //this.sendFile(id, apii.data, 'pp.jpg', text, null, false, { mentions: [user] }, { quoted: fkontak2 })
717
+ } } }
718
+
719
+ break
720
+ case 'promote' :
721
+ case 'daradmin' :
722
+ case 'darpoder' :
723
+ text = ( chat . sPromote || this . spromote || conn . spromote || '@user ```is now Admin```' )
724
+ case 'demote' :
725
+ case 'quitarpoder' :
726
+ case 'quitaradmin' :
727
+ if ( ! text )
728
+ text = ( chat . sDemote || this . sdemote || conn . sdemote || '@user ```is no longer Admin```' )
729
+ text = text . replace ( '@user' , '@' + participants [ 0 ] . split ( '@' ) [ 0 ] )
730
+ if ( chat . detect )
731
+ //this.sendMessage(id, { text, mentions: this.parseMention(text) })
732
+ break
733
+ } }
738
734
739
735
/**
740
736
* Handle groups update
741
- * @param {import('@whiskeysockets /baileys').BaileysEventMap<unknown>['groups.update'] } groupsUpdate
737
+ * @param {import('@adiwajshing /baileys').BaileysEventMap<unknown>['groups.update'] } groupsUpdate
742
738
*/
739
+ export async function groupsUpdate ( groupsUpdate ) {
740
+ if ( opts [ 'self' ] && ! isOwner && ! isROwner )
741
+ return
742
+ for ( const groupUpdate of groupsUpdate ) {
743
+ const id = groupUpdate . id
744
+ if ( ! id ) continue
745
+ let chats = global . db . data ?. chats ?. [ id ] , text = ''
746
+ if ( ! chats ?. detect ) continue
747
+ // if (groupUpdate.desc) text = (chats.sDesc || this.sDesc || conn.sDesc || '```Description has been changed to```\n@desc').replace('@desc', groupUpdate.desc)
748
+ //if (groupUpdate.subject) text = (chats.sSubject || this.sSubject || conn.sSubject || '```Subject has been changed to```\n@subject').replace('@subject', groupUpdate.subject)
749
+ //if (groupUpdate.icon) text = (chats.sIcon || this.sIcon || conn.sIcon || '```Icon has been changed to```').replace('@icon', groupUpdate.icon)
750
+ //if (groupUpdate.revoke) text = (chats.sRevoke || this.sRevoke || conn.sRevoke || '```Group link has been changed to```\n@revoke').replace('@revoke', groupUpdate.revoke)
751
+ if ( ! text ) continue
752
+ await this . sendMessage ( id , { text, mentions : this . parseMention ( text ) } )
753
+ } }
754
+
743
755
744
756
745
- global . db = global . db || { } ; // Initialize global.db if undefined
746
- global . db . data = global . db . data || { } ; // Initialize global.db.data if undefined
747
- global . db . data . lastGroupUpdate = global . db . data . lastGroupUpdate || { } ; // Initialize lastGroupUpdate
748
757
749
- export async function groupsUpdate ( groupsUpdate ) {
750
- if ( opts [ 'self' ] ) return ;
751
- for ( const groupUpdate of groupsUpdate ) {
752
- const id = groupUpdate . id ;
753
- if ( ! id ) continue ;
754
- let chats = global . db . data . chats [ id ] ;
755
- if ( ! chats ?. detect ) continue ;
756
- if ( global . db . data . lastGroupUpdate [ id ] && global . db . data . lastGroupUpdate [ id ] >= Date . now ( ) - 30000 ) continue ; // Skip updates within 30 seconds
757
- global . db . data . lastGroupUpdate [ id ] = Date . now ( ) ; // Update timestamp
758
- let text = '' ;
759
- if ( groupUpdate . desc ) text = ( chats . sDesc || this . sDesc || conn . sDesc || 'Description changed to \n@desc' ) . replace ( '@desc' , groupUpdate . desc ) ;
760
- if ( groupUpdate . subject ) text = ( chats . sSubject || this . sSubject || conn . sSubject || 'The name of the group changed to \n@group' ) . replace ( '@group' , groupUpdate . subject ) ;
761
- if ( groupUpdate . icon ) text = ( chats . sIcon || this . sIcon || conn . sIcon || 'The group icon changed to' ) . replace ( '@icon' , groupUpdate . icon ) ;
762
- if ( groupUpdate . revoke ) text = ( chats . sRevoke || this . sRevoke || conn . sRevoke || 'Group link changes to\n@revoke' ) . replace ( '@revoke' , groupUpdate . revoke ) ;
763
- if ( ! text ) continue ;
764
- await this . sendMessage ( id , { text, mentions : this . parseMention ( text ) } ) ;
765
- }
766
- }
767
758
768
759
769
760
/*Antcall*/
0 commit comments