-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivityKotlin.kt
85 lines (71 loc) · 3.41 KB
/
MainActivityKotlin.kt
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
package smith.test
import android.os.Bundle
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import smith.lib.net.reporter.*
class MainActivityKotlin: AppCompatActivity(), ReporterCallBack {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val et = findViewById<EditText>(R.id.et)
val webhookURL = "https://discord.com/api.........."
val content = et.text.toString()
val username = "SReporter"
val avatarURL = "https://te.legra.ph/file/e86668a3699571a74c411.png"
val tts = true
val dr = DiscReporter(this)
dr.setWeebHook(webhookURL)
dr.setUsername(username)
dr.setAvatarUrl(avatarURL)
dr.setContent(content)
dr.setReportCallBack(this)
dr.setTts(tts)
dr.addEmbed(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(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()
val token = "19521......-6JQ"
val id = "@smith_com"
val header = "" // keep it empty to use default header from library
val subHeader = "This is sub header"
val body = "Testing TeleReporter lib new update...\nThis is report body message\n" + et.text.toString()
val footer = "This is custom footer" // or keep it empty to use default library footer
val tr = TeleReporter(this)
tr.setBotToken(token)
tr.setTargetChatId(id)
tr.setTargetChatTopic(123456789) // optional
tr.setReportHeader(header)
tr.setReportSubHeader(subHeader) // optional
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(this)
tr.sendReport()
}
override fun onSuccess() {
Toast.makeText(this, "REPORT SUCCEED!", Toast.LENGTH_SHORT).show()
}
override fun onFailure(failureMessage: String) {
Toast.makeText(this, failureMessage, Toast.LENGTH_SHORT).show()
}
}