mirror of
https://github.com/HMCore/Orbot.git
synced 2025-12-10 21:06:18 +00:00
Add more extensive fake update capabilities
This commit is contained in:
45
.idea/workspace.xml
generated
45
.idea/workspace.xml
generated
@@ -4,23 +4,13 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Add shards count configuration">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" afterDir="false" />
|
||||
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Add Twitter integration Add Job Listening Integration Various Refactorings">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DataIO.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DataIO.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Main.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Jsoup.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Jsoup.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/JobListingPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/JobListingPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/BlogPostParser.kt" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/JobListingParser.kt" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt" afterDir="false" />
|
||||
</list>
|
||||
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Channels.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Channels.kt" afterDir="false" />
|
||||
</list>
|
||||
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="Changes by Valentin" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@@ -229,7 +219,7 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1597322033373</updated>
|
||||
<workItem from="1622225780094" duration="6687000" />
|
||||
<workItem from="1622225780094" duration="7689000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Add auto publish feature">
|
||||
<created>1597437833375</created>
|
||||
@@ -287,7 +277,28 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622226400158</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="9" />
|
||||
<task id="LOCAL-00009" summary="Add Twitter integration Add Job Listening Integration Various Refactorings">
|
||||
<created>1622232573135</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622232573135</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00010" summary="Changes by Valentin">
|
||||
<created>1622232601071</created>
|
||||
<option name="number" value="00010" />
|
||||
<option name="presentableId" value="LOCAL-00010" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622232601071</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00011" summary="Changes by Valentin">
|
||||
<created>1622232613740</created>
|
||||
<option name="number" value="00011" />
|
||||
<option name="presentableId" value="LOCAL-00011" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622232613740</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="12" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -314,7 +325,9 @@
|
||||
<MESSAGE value="Update Json Serialization" />
|
||||
<MESSAGE value="Update stuff" />
|
||||
<MESSAGE value="Add shards count configuration" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add shards count configuration" />
|
||||
<MESSAGE value="Add Twitter integration Add Job Listening Integration Various Refactorings" />
|
||||
<MESSAGE value="Changes by Valentin" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Changes by Valentin" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.wulkanat
|
||||
|
||||
import de.wulkanat.web.fakeUpdateBlogPost
|
||||
import de.wulkanat.web.fakeUpdateJobListings
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||
import net.dv8tion.jda.api.EmbedBuilder
|
||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent
|
||||
@@ -23,13 +24,19 @@ class AdminCli : ListenerAdapter() {
|
||||
when (command[0].value) {
|
||||
"stop" -> exitProcess(1)
|
||||
"fakeUpdate" -> {
|
||||
// TODO: implement fake update for blog posts
|
||||
// BLOG_POST_WATCHER.current = setOf()
|
||||
fakeUpdateBlogPost()
|
||||
if (command.size < 2) {
|
||||
Admin.println("Specify type")
|
||||
} else {
|
||||
val amount = command.getOrNull(2)?.value?.trim('`')?.toIntOrNull() ?: 1
|
||||
when (command[1].value.trim('`')) {
|
||||
"blog" -> fakeUpdateBlogPost(amount)
|
||||
"twitter" -> TwitterJob.lastTweetID = "poggers"
|
||||
"jobs" -> fakeUpdateJobListings(amount)
|
||||
else -> Admin.println("Must be blog|twitter|jobs")
|
||||
}
|
||||
|
||||
TwitterJob.lastTweetID = "poggers"
|
||||
|
||||
Admin.println("Posting on next update cycle.")
|
||||
Admin.println("Posting $amount on next update cycle.")
|
||||
}
|
||||
}
|
||||
"info" -> {
|
||||
Admin.info()
|
||||
@@ -66,7 +73,7 @@ class AdminCli : ListenerAdapter() {
|
||||
"""
|
||||
**${prefix}stop**
|
||||
Stop the bot
|
||||
**${prefix}fakeUpdate**
|
||||
**${prefix}fakeUpdate [blog|twitter|jobs] [amount]**
|
||||
Post a fake update to every registered channel (can be used if bot missed the update)
|
||||
**${prefix}info**
|
||||
Show an overview over all registered channels
|
||||
|
||||
@@ -8,7 +8,7 @@ import de.wulkanat.model.BlogPostPreview
|
||||
import de.wulkanat.model.JobListingPreview
|
||||
|
||||
private const val BLOG_POST_STATE_FILE_NAME = "blog_state.json"
|
||||
fun fakeUpdateBlogPost() = removeFirstFromSiteSave<BlogPostPreview>(BLOG_POST_STATE_FILE_NAME)
|
||||
fun fakeUpdateBlogPost(amount: Int = 1) = removeFromSiteSave<BlogPostPreview>(BLOG_POST_STATE_FILE_NAME, amount)
|
||||
fun getNewBlogPosts() = updateSite("https://hytale.com/news", BLOG_POST_STATE_FILE_NAME) { doc ->
|
||||
doc["postWrapper"].map {
|
||||
BlogPostPreview(
|
||||
@@ -23,7 +23,7 @@ fun getNewBlogPosts() = updateSite("https://hytale.com/news", BLOG_POST_STATE_FI
|
||||
}
|
||||
|
||||
private const val JOB_LISTING_STATE_FILE_NAME = "jobs_state.json"
|
||||
fun fakeUpdateJobListings() = removeFirstFromSiteSave<JobListingPreview>(JOB_LISTING_STATE_FILE_NAME)
|
||||
fun fakeUpdateJobListings(amount: Int = 1) = removeFromSiteSave<JobListingPreview>(JOB_LISTING_STATE_FILE_NAME, amount)
|
||||
fun getNewJobListings() = updateSite("https://hypixelstudios.com/jobs/", JOB_LISTING_STATE_FILE_NAME) { doc ->
|
||||
doc["current-jobs__departments"].flatMap { jobDepartment ->
|
||||
val jobDepartmentName = jobDepartment["current-jobs__department-name"].text
|
||||
|
||||
@@ -11,10 +11,15 @@ import java.io.IOException
|
||||
/**
|
||||
* Removes the first element of a saved JSON list file
|
||||
*/
|
||||
inline fun <reified T>
|
||||
removeFirstFromSiteSave(fileName: String) = File(fileName).takeIf { it.exists() }?.let {
|
||||
it.writeText(Json.encodeToString(Json.decodeFromString<List<T>>(it.readText()).toMutableList().apply { removeFirst() }))
|
||||
}
|
||||
inline fun <reified T> removeFromSiteSave(fileName: String, amount: Int = 1) =
|
||||
File(fileName).takeIf { it.exists() }?.let {
|
||||
it.writeText(
|
||||
if (amount >= 0) Json.encodeToString(
|
||||
Json.decodeFromString<List<T>>(it.readText()).subList(0, amount)
|
||||
)
|
||||
else "[]"
|
||||
)
|
||||
}
|
||||
|
||||
inline fun <reified T> updateSite(url: String, fileName: String, parser: (Document) -> List<T>) = try {
|
||||
val currentStateFile = File(fileName)
|
||||
|
||||
Reference in New Issue
Block a user