-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
85 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/xiaoyv404/mirai/app/fsh/CommandHistory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.xiaoyv404.mirai.app.fsh | ||
|
||
import com.xiaoyv404.mirai.core.App | ||
import com.xiaoyv404.mirai.core.gid | ||
import com.xiaoyv404.mirai.core.uid | ||
import com.xiaoyv404.mirai.dao.save | ||
import com.xiaoyv404.mirai.model.HistoryRecord | ||
import net.mamoe.mirai.event.events.MessageEvent | ||
import net.mamoe.mirai.message.data.ids | ||
import java.time.Instant | ||
import java.time.LocalDateTime | ||
import java.time.ZoneId | ||
import java.time.ZoneOffset | ||
|
||
@App | ||
object CommandHistory { | ||
fun add(command: String, msg: MessageEvent) { | ||
HistoryRecord { | ||
this.sendTime = LocalDateTime.ofInstant( | ||
Instant.ofEpochSecond(msg.time.toLong() + 10800), ZoneId.ofOffset( | ||
"UTC", | ||
ZoneOffset.of("+18") | ||
) | ||
) | ||
this.command = command | ||
this.gid = msg.gid() | ||
this.uid = msg.uid() | ||
this.msgId = msg.message.ids[0].toLong() | ||
this.content = msg.message.contentToString() | ||
}.save() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
src/main/kotlin/com/xiaoyv404/mirai/app/history/process.kt
This file was deleted.
Oops, something went wrong.
21 changes: 9 additions & 12 deletions
21
src/main/kotlin/com/xiaoyv404/mirai/model/HistoryRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
package com.xiaoyv404.mirai.model | ||
|
||
import org.ktorm.entity.* | ||
import org.ktorm.entity.Entity | ||
import org.ktorm.schema.* | ||
import java.time.* | ||
import java.time.LocalDateTime | ||
|
||
interface HistoryRecord : Entity<HistoryRecord> { | ||
companion object : Entity.Factory<HistoryRecord>() | ||
|
||
val id: Long | ||
var sendTime: LocalDateTime | ||
var eventType: String | ||
var groupId: Long | ||
var groupName: String | ||
var senderId: Long | ||
var senderName: String | ||
var command: String | ||
var gid: Long | ||
var uid: Long | ||
var msgId: Long | ||
var content: String | ||
} | ||
|
||
object HistoryRecords : Table<HistoryRecord>("History_Record") { | ||
val id = long("id").primaryKey().bindTo { it.id } | ||
val sendTime = datetime("send_time").bindTo { it.sendTime } | ||
val eventType = varchar("event_type").bindTo { it.eventType } | ||
val groupId = long("group_id").bindTo { it.groupId } | ||
val groupName = varchar("group_name").bindTo { it.groupName } | ||
val senderId = long("sender_id").bindTo { it.senderId } | ||
val senderName = varchar("sender_name").bindTo { it.senderName } | ||
val eventType = varchar("command").bindTo { it.command } | ||
val groupId = long("group_id").bindTo { it.gid } | ||
val senderId = long("sender_id").bindTo { it.uid } | ||
val msgId = long("msg_id").bindTo { it.msgId } | ||
val content = text("content").bindTo { it.content } | ||
} |