Skip to content

smith8h/SReporter

Repository files navigation

SReporter

Build Status stability-stable minimumSDK stable version Repository size


Content


Setup

Step 1. Add the JitPack repository to your build file.
Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
	...
	maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency:

dependencies {
    implementation 'com.github.smith8h:SReporter:v2.1'
}

Documentations

Send reports, notifications, app crash logs and etc.. simply with SReporter library. You can choose how to send reports to your Telegram group by Telegram APIs or to your Discord server by Discord Webhooks! Well with SReporter you can send them properly. Follow the instructions below on how to implement TeleReporter and DiscReporter classes:

TeleReporter

The TeleReport composed of Header, SubHeader ( optional ), Message or Body and Footer. As in the image bellow:


  • Create new object of TeleReporter class:
        TeleReporter tr = new TeleReporter(this);
  • Now set your Telegram bot token:
        tr.setBotToken("19521... ...-6JQ");

    📃 Go to Telegram BotFather and create or surf your bots and get its token

  • Now set your target chat id (or username):
        tr.setTargetChatId("@smith_com");
        // or chat id (1323671558)
    • (Optional) to send message to specific topic in your super group, set target topic (Thread Message ID). You need to go through your topic (To when you initialized the topic) and get the info of this message "Topic Created..." as json and copy its message_thread_id and paste it here:
        tr.setTargetChatTopic(1234567890);
  • Set Header for the report:
        tr.setReportHeader("Report Title (Report Header)...");
        // You can leave it blank for default title
  • Set SubHeader for the report:
        tr.setReportSubHeader("SubTitle (SubHeader)...");
        // You can leave it blank if you don't want it to be in the report
  • Set the content of the report:
        tr.setReportMessage("Report Content...");
  • Set the footer of the report:
        tr.setReportFooter(TeleReporter.USER_INFO, "");
        // Default footer is the info of user's device, build, app used, app version...
        
        tr.setReportFooter(TeleReporter.CUSTOM, "Custom Footer...");
        // Custom footer info (additional note) if you don't need to attach device & app info of the user
  • Now set the callback interface to get notified of errors or successes of sending reports:
        tr.setReportCallBack(callback);

    Head straight to CallBack Implementation to see how to implement the callback for TeleReporter.

  • Now send the report to your chat/group
        tr.sendReport();

DiscReporter

The DiscReport composed of main report content ( consider it like a header or the main message if you don't need to use the embeds ), Embeds ( optional, ImageEmbed/AuthorEmbed/ThumbnailEmbed/FooterEmbed/Fields ). As in the image bellow:


  • Create new object of TeleReporter class:
        DiscReporter dr = new DiscReporter(this);
  • Now set your Discord server's webhook url:
        dr.setWeebHook("https://discord.com/api...");

    📃 See instructions here to create new webhook for your Discord server.

  • Now set a username for webhook:
        dr.setUsername("SReporter");
        // optional, put your desired one instead
  • Set an icon for webhook:
        dr.setAvatarUrl("https://te.legra.ph/file/e86668a3699571a74c411.png");
        // default is the lib icon
  • Now set your content of the report, either as title if you want to use embeds or as main content if you won't:
        dr.setContent("Content text...");
  • If you want to set tts to the report:
        dr.setTts(true);
        // default is false
  • Now if you want to add embeds:
        dr.addEmbed(embed)
        // you can add as many as you need

    Head straight to DiscReporter Embeds to see how to implement embeds for DiscReporter.

  • Now set the callback interface to get notified of errors or successes of sending reports:
        dr.setReportCallBack(callback);

    Head straight to CallBack Implementation to see how to implement the callback for DiscReporter.

  • Now send the report to your server:
        dr.sendReport();

DiscReporter Embeds

You can dismiss using the embeds and just rely on title, description and url Also you can customize it to your prefers! considering title, author, thumbnail and without the inline fields and footer... etc.

    DiscEmbed embed = new DiscEmbed.Builder()
            .setTitle("Title")
            .setDescription("Description")
            .setURL("https://t.me/smithdev")
            
            // author name, author url, author icon
            .setAuthorEmbed("Name","https://t.me/smithdev","https://te.legra.ph/file/e86668a3699571a74c411.png")
            
            // footer text, footer icon
            .setFooterEmbed("thank in advance","https://te.legra.ph/file/e86668a3699571a74c411.png")
            
            // image url
            .setImageEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
            
            // thumbnail url
            .setThumbnailEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
            
            // inline fields (Copy on click)
            .addFieldEmbed("Field inline", "field value")
            
            .build());

CallBack

    ReporterCallBack callback = new ReporterCallBack() {
        @Override
        public void onSuccess() {
            Toast.makeText(context, "REPORT SENT SUCCEESSFULLY!", Toast.LENGTH_SHORT).show();
        }
        
        @Override
        public void onFailure(String failureMessage) {
            Toast.makeText(context, failureMessage, Toast.LENGTH_SHORT).show();
        }
    };

Demo Codes

You can find full demo codes for Java and Kotlin here:

Java Codes See demo codes for Java
Kotlin Codes See demo codes for Kotlin

Donations

If you would like to support this project's further development, the creator of this projects or the continuous maintenance of the project feel free to donate. Your donation is highly appreciated. Thank you!


You can choose what you want to donate, all donations are awesome!

Buy me a coffee



With ❤️

About

SReporter library, send reports, crash logs, notifications and more messages from your app to your Telegram group or/and Discord server.

Resources

Stars

Watchers

Forks

Packages

No packages published