Hello, I would like to introduce you to my new auto-response library for social networks, compatible with whatsapp, telegram works in the background

A good part of the code was recovered from the NotificationListener library I made some modifications to adapt to my project and I'm making available to you the example and the ReplyAuto.rar library.

Sorry for my English, I'm Brazilian and I'm in love with Basic4Android. no more conversations Let's go to the example.

Important minSdkVersion="14" AND android:targetSdkVersion="29"


Manifest:
AddApplicationText(
<service android:name="b4a.jsaplication.com.br.ReplyAuto"
    android:label="ReplyAuto"
          android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
     <intent-filter>
         <action android:name="android.service.notification.NotificationListenerService" />
     </intent-filter>
 </service>)


B4A:
Sub ReplyAuto_NotificationPosted (SBN As StatusBarNotification)
    'Log(SBN.Id) 'get Id Notification
    'Log(SBN.PackageName) 'get PackageName Application posted Notification
    'Log(SBN.Notification) 'get Notification object
    'Log(SBN.Extras)  'get extras Notification
    'Log(SBN.ContentIntent) 'get ContentIntent not used
    'Log(SBN.Key) 'get Key
    'LogColor(SBN.Title, Colors.Green)
    'LogColor(SBN.Message, Colors.Green)
    
    If SBN.PackageName == "com.whatsapp" Then
        Dim whatsappkey As String = SBN.Key
        Dim ww() As String = Regex.Split("\|", whatsappkey)
        If ww(3) <> "null" Then
            'rp.ClearNotification(SBN)
            rp.reply(SBN.Notification, SBN.PackageName, "Reply HelloWorld WhatsApp")
            Log("Reply Whatsapp Success")
        End If
    End If
    

    If SBN.PackageName == "com.whatsapp.w4b" Then
        Dim whatsappkey As String = SBN.Key
        Dim ww() As String = Regex.Split("\|", whatsappkey)
        If ww(3) <> "null" Then
            'rp.ClearNotification(SBN)
            rp.reply(SBN.Notification, SBN.PackageName, "Reply HelloWorld WhatsApp-Business")
            Log("Reply Whatsapp Success")
        End If
    End If
    
    If SBN.PackageName == "org.telegram.messenger.web" Then
        Dim telegramkey As String = SBN.Key
        Dim tt() As String = Regex.Split("\|", telegramkey)
        
        If tt(2).Length <> "1" Then
            rp.reply(SBN.Notification, SBN.PackageName, "Reply HelloWorld Telegram")
            Log("Send Telegram Success")
        End If
    End If
    
    If SBN.PackageName == "org.telegram.messenger" Then
        Dim telegramkey As String = SBN.Key
        Dim tt() As String = Regex.Split("\|", telegramkey)
        
        If tt(2).Length <> "1" Then
            rp.reply(SBN.Notification, SBN.PackageName, "Reply HelloWorld Telegram")
            Log("Send Telegram Success")
        End If
    End If
    

End Sub
 

Attachments

  • ReplyAuto Library.rar
    16.9 KB · Views: 604
  • ReplyAuto.zip
    9.5 KB · Views: 573

cheveguerra

Member
Licensed User
Longtime User
I don't think so, because you are replying to a notification and it only accepts text replies.
It is an Android restriction.
 

jsaplication.mobile

Member
Licensed User
Hi, this is very useful. Specially after Meta's new policies.

Is it possible to receive and save photo/files/audio/location? And also send them?

Oi, isto será muito útil. Especialmente depois das noves políticas da Meta.

É possível receber e salvar fotos/arquivos/audio/localização? E também tem como enviá-los?
at the moment there is no way to save or send files but i am working on the library and adding some new functions
 

cheveguerra

Member
Licensed User
Longtime User
Hi, this is very useful. Specially after Meta's new policies.

Is it possible to receive and save photo/files/audio/location? And also send them?

Oi, isto será muito útil. Especialmente depois das noves políticas da Meta.

É possível receber e salvar fotos/arquivos/audio/localização? E também tem como enviá-los?
You can receive stickers, location and images, but you can only access the text of the notification, in the case of location you only get a "pin" icon and the text "location", when receiving a sticker you get another icon an "sticker" or "GIF" as text and so and so!.

receive a gif -> 👾 GIF
receive a sticker -> 💟 Sticker
receive location -> 📌 Location
receive a photo -> 📷 Photo
 

juventino883

Member
Licensed User
Longtime User
Hi, there is any way to send a message to whatsapp number without having to wait for a notficaton?, I like your library and works great, I'm curious how you manage to send messages to whatsapp without opening the external app?
 

jsaplication.mobile

Member
Licensed User
Hi, there is any way to send a message to whatsapp number without having to wait for a notficaton?, I like your library and works great, I'm curious how you manage to send messages to whatsapp without opening the external app?
Hey. I'm adding an option to send a message without having to receive a notification so the first notification will have to arrive in order to save the chat channel in the system. and then reuse this channel to simulate a fake whatsapp notification so that the app can respond to it without having to send a message.

help by donating paypal:: [email protected]
 

cheveguerra

Member
Licensed User
Longtime User
Hey. I'm adding an option to send a message without having to receive a notification so the first notification will have to arrive in order to save the chat channel in the system. and then reuse this channel to simulate a fake whatsapp notification so that the app can respond to it without having to send a message.

help by donating paypal:: [email protected]
Were you able to send a message without a previous notification??

Best regards
 
Top