feat: add gravatar command
This commit is contained in:
3 files changed
+48
-2
No files matched your search
@@ -9,6 +9,7 @@ package cn.rtast.fancybot.util.str
|
||||
|
||||
import java.awt.Graphics2D
|
||||
import java.net.URLEncoder
|
||||
import java.security.MessageDigest
|
||||
|
||||
fun setTruncate(origin: String, g2d: Graphics2D, maxWidth: Int = 500): String {
|
||||
val fontMetrics = g2d.fontMetrics
|
||||
@@ -50,4 +51,14 @@ fun Int.formatToMinutes(): String {
|
||||
|
||||
val String.proxy get() = this.replace("https://", "https://proxy.rtast.cn/https/")
|
||||
|
||||
val String.uriEncode get() = URLEncoder.encode(this, "UTF-8")
|
||||
val String.uriEncode get() = URLEncoder.encode(this, "UTF-8")
|
||||
|
||||
fun String.getMD5(): String {
|
||||
return this.toByteArray().getMD5()
|
||||
}
|
||||
|
||||
fun ByteArray.getMD5(): String {
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
val hashBytes = md.digest(this)
|
||||
return hashBytes.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
Reference in New Issue
Block a user