-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.java
96 lines (82 loc) · 3.98 KB
/
MainActivity.java
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
package smith.test;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import smith.lib.net.reporter.DiscEmbed;
import smith.lib.net.reporter.DiscReporter;
import smith.lib.net.reporter.ReporterCallBack;
import smith.lib.net.reporter.TeleReporter;
public class MainActivity extends AppCompatActivity {
ReporterCallBack callback = new ReporterCallBack() {
@Override public void onSuccess() {
Toast.makeText(MainActivity.this, "REPORT SUCCEED!", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(String failureMessage) {
Toast.makeText(MainActivity.this, failureMessage, Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void check(View v) {
EditText et = findViewById(R.id.et);
String webhookURL = "https://discord.com/api..........";
String content = "Some Content to fill the report";
String username = "SReporter";
String avatarURL = "https://te.legra.ph/file/e86668a3699571a74c411.png";
boolean tts = true;
DiscReporter dr = new DiscReporter(this);
dr.setWeebHook(webhookURL);
dr.setUsername(username);
dr.setAvatarUrl(avatarURL);
dr.setContent(content);
dr.setReportCallBack(callback);
dr.setTts(tts);
dr.addEmbed(new DiscEmbed.Builder()
.setDescription("Description")
.setTitle("Title")
.setURL("https://t.me/smithdev")
.setAuthorEmbed("Author smith8h","https://t.me/smithdev","https://te.legra.ph/file/e86668a3699571a74c411.png")
.setFooterEmbed("footer embed","https://te.legra.ph/file/e86668a3699571a74c411.png")
.setImageEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
.setThumbnailEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
.addFieldEmbed("Field inline", "field value")
.addFieldEmbed("field inline", "field value")
.build());
dr.addEmbed(new DiscEmbed.Builder()
.setDescription("Description")
.setTitle("Title")
.setURL("https://t.me/smithdev")
.setAuthorEmbed("Author smith8h","https://t.me/smithdev","https://te.legra.ph/file/e86668a3699571a74c411.png")
.setFooterEmbed("footer embed","https://te.legra.ph/file/e86668a3699571a74c411.png")
.setImageEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
.setThumbnailEmbed("https://te.legra.ph/file/e86668a3699571a74c411.png")
.addFieldEmbed("Field inline", "field value")
.addFieldEmbed("field inline", "field value")
.build());
dr.sendReport();
String token = "19521......-6JQ";
String id = "@smith_com";
String header = ""; // keep it empty to use default header from library
String subHeader = "This is sub header";
String body = "Testing TeleReporter lib new update...\nThis is report body message\n"
+ et.getText().toString();
String footer = "This is custom footer"; // or keep it empty to use default library footer
TeleReporter tr = new TeleReporter(this);
tr.setBotToken(token);
tr.setTargetChatId(id);
tr.setTargetChatTopic(123456789);
tr.setReportHeader(header);
tr.setReportSubHeader(subHeader);
tr.setReportMessage(body);
tr.setReportFooter(TeleReporter.USER_INFO, ""); // keep it empty to use default footer from library
tr.setReportFooter(TeleReporter.CUSTOM, footer); // custom footer from your app
tr.setReportCallBack(callback);
tr.sendReport();
}
}