mirror of
https://github.com/HMCore/Orbot.git
synced 2025-12-12 13:56:18 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcaa8377c1 | ||
|
|
4c4e4dc992 | ||
|
|
8b98d4ba3c | ||
|
|
0877883e3c | ||
|
|
a78c2343da | ||
|
|
490a5dcd41 | ||
|
|
5969a2f221 | ||
|
|
e58f4dc0c5 | ||
|
|
2c7797c112 | ||
|
|
7bf483ab32 | ||
|
|
2741206977 | ||
|
|
d15fb92acf |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
servers.json
|
servers.json
|
||||||
admin.json
|
admin.json
|
||||||
|
service_channels.json
|
||||||
*.hprof
|
*.hprof
|
||||||
/build
|
/build
|
||||||
/.gradle
|
/.gradle
|
||||||
16
.idea/codeStyles/Project.xml
generated
16
.idea/codeStyles/Project.xml
generated
@@ -1,6 +1,22 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
|
<value>
|
||||||
|
<package name="java.util" alias="false" withSubpackages="false" />
|
||||||
|
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||||
|
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||||
|
<value>
|
||||||
|
<package name="" alias="false" withSubpackages="true" />
|
||||||
|
<package name="java" alias="false" withSubpackages="true" />
|
||||||
|
<package name="javax" alias="false" withSubpackages="true" />
|
||||||
|
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||||
|
<package name="" alias="true" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<codeStyleSettings language="kotlin">
|
<codeStyleSettings language="kotlin">
|
||||||
|
|||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/dictionaries/wulkanat.xml
generated
Normal file
8
.idea/dictionaries/wulkanat.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="wulkanat">
|
||||||
|
<words>
|
||||||
|
<w>crosspost</w>
|
||||||
|
<w>hytale</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
||||||
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
313
.idea/workspace.xml
generated
313
.idea/workspace.xml
generated
@@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="">
|
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="no idea what that did">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DiscordRpc.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DiscordRpc.kt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Admin.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Admin.kt" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Cli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Cli.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" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -31,52 +31,6 @@
|
|||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||||
</path>
|
</path>
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Source Sets" type="e897c970:GradleViewContributor$SourceSetsNode" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="build" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="build setup" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="documentation" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="help" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="other" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
|
||||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
|
||||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
|
||||||
<item name="verification" type="c8890929:TasksNode$1" />
|
|
||||||
</path>
|
|
||||||
</expand>
|
</expand>
|
||||||
<select />
|
<select />
|
||||||
</tree_state>
|
</tree_state>
|
||||||
@@ -87,24 +41,37 @@
|
|||||||
<component name="FileTemplateManagerImpl">
|
<component name="FileTemplateManagerImpl">
|
||||||
<option name="RECENT_TEMPLATES">
|
<option name="RECENT_TEMPLATES">
|
||||||
<list>
|
<list>
|
||||||
<option value="Kotlin File" />
|
<option value="Class" />
|
||||||
<option value="Kotlin Class" />
|
<option value="Kotlin Class" />
|
||||||
<option value="Kotlin Object" />
|
<option value="Kotlin Object" />
|
||||||
|
<option value="Kotlin File" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
|
<map>
|
||||||
|
<entry key="$PROJECT_DIR$" value="not-sure" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<setting file="file://$PROJECT_DIR$/build.gradle" root0="SKIP_INSPECTION" />
|
||||||
|
</component>
|
||||||
|
<component name="MacroExpansionManager">
|
||||||
|
<option name="directoryName" value="o7p0t8es" />
|
||||||
|
</component>
|
||||||
<component name="ProjectId" id="1g2oQiuUv1Bu6ZCW2NSVzB1V6Sc" />
|
<component name="ProjectId" id="1g2oQiuUv1Bu6ZCW2NSVzB1V6Sc" />
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showExcludedFiles" value="true" />
|
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
|
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||||
|
<property name="last_opened_file_path" value="$PROJECT_DIR$/build/libs" />
|
||||||
<property name="project.structure.last.edited" value="Modules" />
|
<property name="project.structure.last.edited" value="Modules" />
|
||||||
<property name="project.structure.proportion" value="0.15" />
|
<property name="project.structure.proportion" value="0.15" />
|
||||||
<property name="project.structure.side.proportion" value="0.2" />
|
<property name="project.structure.side.proportion" value="0.2" />
|
||||||
@@ -114,12 +81,58 @@
|
|||||||
<key name="MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY">
|
<key name="MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY">
|
||||||
<recent name="de.wulkanat" />
|
<recent name="de.wulkanat" />
|
||||||
</key>
|
</key>
|
||||||
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot\build\libs" />
|
||||||
|
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot\src" />
|
||||||
|
</key>
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot\src\main\kotlin\de\wulkanat" />
|
|
||||||
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot" />
|
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot" />
|
||||||
|
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot\src\main\kotlin\de\wulkanat" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="JAR Application.HytaleUpdateBot-all-1.0-SNAPSHOT.jar">
|
<component name="RunManager" selected="Application.MainKt">
|
||||||
|
<configuration name="HytaleUpdateBot [build]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||||
|
<ExternalSystemSettings>
|
||||||
|
<option name="executionName" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="externalSystemIdString" value="GRADLE" />
|
||||||
|
<option name="scriptParameters" />
|
||||||
|
<option name="taskDescriptions">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="taskNames">
|
||||||
|
<list>
|
||||||
|
<option value="build" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="vmOptions" />
|
||||||
|
</ExternalSystemSettings>
|
||||||
|
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||||
|
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||||
|
<DebugAllEnabled>false</DebugAllEnabled>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="HytaleUpdateBot [clean]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||||
|
<ExternalSystemSettings>
|
||||||
|
<option name="executionName" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="externalSystemIdString" value="GRADLE" />
|
||||||
|
<option name="scriptParameters" />
|
||||||
|
<option name="taskDescriptions">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="taskNames">
|
||||||
|
<list>
|
||||||
|
<option value="clean" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="vmOptions" />
|
||||||
|
</ExternalSystemSettings>
|
||||||
|
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||||
|
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||||
|
<DebugAllEnabled>false</DebugAllEnabled>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
<configuration name="HytaleUpdateBot [fatJar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
<configuration name="HytaleUpdateBot [fatJar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||||
<ExternalSystemSettings>
|
<ExternalSystemSettings>
|
||||||
<option name="executionName" />
|
<option name="executionName" />
|
||||||
@@ -136,50 +149,38 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="vmOptions" />
|
<option name="vmOptions" />
|
||||||
</ExternalSystemSettings>
|
</ExternalSystemSettings>
|
||||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
|
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||||
<method v="2" />
|
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||||
</configuration>
|
<DebugAllEnabled>false</DebugAllEnabled>
|
||||||
<configuration name="HytaleUpdateBot [jar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
|
||||||
<ExternalSystemSettings>
|
|
||||||
<option name="executionName" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="externalSystemIdString" value="GRADLE" />
|
|
||||||
<option name="scriptParameters" />
|
|
||||||
<option name="taskDescriptions">
|
|
||||||
<list />
|
|
||||||
</option>
|
|
||||||
<option name="taskNames">
|
|
||||||
<list>
|
|
||||||
<option value="jar" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="vmOptions" />
|
|
||||||
</ExternalSystemSettings>
|
|
||||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="HytaleUpdateBot-1.0-SNAPSHOT-all.jar" type="JarApplication" temporary="true">
|
|
||||||
<option name="JAR_PATH" value="$PROJECT_DIR$/build/libs/HytaleUpdateBot-1.0-SNAPSHOT-all.jar" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="HytaleUpdateBot-1.0-SNAPSHOT.jar" type="JarApplication" temporary="true">
|
|
||||||
<option name="JAR_PATH" value="$PROJECT_DIR$/build/libs/HytaleUpdateBot-1.0-SNAPSHOT.jar" />
|
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="HytaleUpdateBot-all-1.0-SNAPSHOT.jar" type="JarApplication" temporary="true">
|
<configuration name="HytaleUpdateBot-all-1.0-SNAPSHOT.jar" type="JarApplication" temporary="true">
|
||||||
<option name="JAR_PATH" value="$PROJECT_DIR$/build/libs/HytaleUpdateBot-all-1.0-SNAPSHOT.jar" />
|
<option name="JAR_PATH" value="$PROJECT_DIR$/build/libs/HytaleUpdateBot-all-1.0-SNAPSHOT.jar" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="MainKt" type="JetRunConfigurationType" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="HytaleUpdateBot.main" />
|
||||||
|
<option name="VM_PARAMETERS" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" />
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="de.wulkanat.MainKt" />
|
||||||
|
<option name="WORKING_DIRECTORY" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="JAR Application.HytaleUpdateBot-all-1.0-SNAPSHOT.jar" />
|
|
||||||
<item itemvalue="JAR Application.HytaleUpdateBot-1.0-SNAPSHOT-all.jar" />
|
|
||||||
<item itemvalue="Gradle.HytaleUpdateBot [fatJar]" />
|
<item itemvalue="Gradle.HytaleUpdateBot [fatJar]" />
|
||||||
<item itemvalue="JAR Application.HytaleUpdateBot-1.0-SNAPSHOT.jar" />
|
<item itemvalue="Gradle.HytaleUpdateBot [build]" />
|
||||||
<item itemvalue="Gradle.HytaleUpdateBot [jar]" />
|
<item itemvalue="Gradle.HytaleUpdateBot [clean]" />
|
||||||
|
<item itemvalue="JAR Application.HytaleUpdateBot-all-1.0-SNAPSHOT.jar" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="project-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="SvnConfiguration">
|
<component name="SvnConfiguration">
|
||||||
<configuration />
|
<configuration />
|
||||||
</component>
|
</component>
|
||||||
@@ -191,84 +192,74 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1597322033373</updated>
|
<updated>1597322033373</updated>
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="Add auto publish feature">
|
||||||
|
<created>1597437833375</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1597437833375</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00002" summary="Add auto publish feature">
|
||||||
|
<created>1597438052596</created>
|
||||||
|
<option name="number" value="00002" />
|
||||||
|
<option name="presentableId" value="LOCAL-00002" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1597438052596</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00003" summary="[1.1]">
|
||||||
|
<created>1597438317540</created>
|
||||||
|
<option name="number" value="00003" />
|
||||||
|
<option name="presentableId" value="LOCAL-00003" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1597438317540</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00004" summary="Add service announcement channel">
|
||||||
|
<created>1597839954908</created>
|
||||||
|
<option name="number" value="00004" />
|
||||||
|
<option name="presentableId" value="LOCAL-00004" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1597839954909</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00005" summary="prepare twitter integration">
|
||||||
|
<created>1601042375685</created>
|
||||||
|
<option name="number" value="00005" />
|
||||||
|
<option name="presentableId" value="LOCAL-00005" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1601042375685</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="6" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="WindowStateProjectService">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
<state x="552" y="179" key="#Project_Structure" timestamp="1597338262424">
|
<option name="TAB_STATES">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<map>
|
||||||
</state>
|
<entry key="MAIN">
|
||||||
<state x="552" y="179" key="#Project_Structure/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597338262424" />
|
<value>
|
||||||
<state x="-1050" y="581" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1597352463714">
|
<State />
|
||||||
<screen x="-1050" y="105" width="1050" height="1640" />
|
</value>
|
||||||
</state>
|
</entry>
|
||||||
<state x="-1050" y="581" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597352463714" />
|
</map>
|
||||||
<state x="633" y="446" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog" timestamp="1597362173063">
|
</option>
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<option name="oldMeFiltersMigrated" value="true" />
|
||||||
</state>
|
</component>
|
||||||
<state x="633" y="446" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362173063" />
|
<component name="VcsManagerConfiguration">
|
||||||
<state x="739" y="173" width="484" height="693" key="#org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog" timestamp="1597362199927">
|
<MESSAGE value="Add auto publish feature" />
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<MESSAGE value="[1.1]" />
|
||||||
</state>
|
<MESSAGE value="Add service announcement channel" />
|
||||||
<state x="739" y="173" width="484" height="693" key="#org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362199927" />
|
<MESSAGE value="fix crash on missing permission add removeInactive command" />
|
||||||
<state x="128" y="270" width="490" height="591" key="#xdebugger.evaluate" timestamp="1597332665464">
|
<MESSAGE value="prepare twitter integration" />
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<option name="LAST_COMMIT_MESSAGE" value="prepare twitter integration" />
|
||||||
</state>
|
|
||||||
<state x="128" y="270" width="490" height="591" key="#xdebugger.evaluate/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597332665464" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.bottom" timestamp="1597362407964">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329412" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362407964" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.center" timestamp="1597362407964">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.0.center/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329411" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.center/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362407964" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.left" timestamp="1597362407964">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.0.left/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329411" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.left/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362407964" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.right" timestamp="1597362407964">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.0.right/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329411" />
|
|
||||||
<state width="1876" height="161" key="GridCell.Tab.0.right/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597362407964" />
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.bottom" timestamp="1597351329412">
|
|
||||||
<screen x="-1050" y="105" width="1050" height="1640" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.bottom/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329412" />
|
|
||||||
<state width="1876" height="348" key="GridCell.Tab.1.bottom/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597339868293" />
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.center" timestamp="1597351329412">
|
|
||||||
<screen x="-1050" y="105" width="1050" height="1640" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.center/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329412" />
|
|
||||||
<state width="1876" height="348" key="GridCell.Tab.1.center/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597339868293" />
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.left" timestamp="1597351329412">
|
|
||||||
<screen x="-1050" y="105" width="1050" height="1640" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.left/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329412" />
|
|
||||||
<state width="1876" height="348" key="GridCell.Tab.1.left/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597339868293" />
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.right" timestamp="1597351329412">
|
|
||||||
<screen x="-1050" y="105" width="1050" height="1640" />
|
|
||||||
</state>
|
|
||||||
<state width="1006" height="588" key="GridCell.Tab.1.right/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597351329412" />
|
|
||||||
<state width="1876" height="348" key="GridCell.Tab.1.right/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597339868293" />
|
|
||||||
<state x="94" y="257" key="SettingsEditor" timestamp="1597361509050">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state x="-1040" y="568" key="SettingsEditor/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@-1050.105.1050.1640" timestamp="1597353858648" />
|
|
||||||
<state x="94" y="257" key="SettingsEditor/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597361509050" />
|
|
||||||
<state x="616" y="240" key="run.anything.popup" timestamp="1597325088886">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state x="616" y="240" key="run.anything.popup/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597325088886" />
|
|
||||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1597333756907">
|
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
|
||||||
</state>
|
|
||||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040/1920.-213.2560.1400/-1050.105.1050.1640@0.0.1920.1040" timestamp="1597333756907" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" type="kotlin-line">
|
||||||
|
<url>file://$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt</url>
|
||||||
|
<line>22</line>
|
||||||
|
<option name="timeStamp" value="1" />
|
||||||
|
</line-breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
<watches-manager>
|
<watches-manager>
|
||||||
<configuration name="JetRunConfigurationType">
|
<configuration name="JetRunConfigurationType">
|
||||||
<watch expression="((org.jsoup.nodes.Element.NodeList)((Document)doc).childNodes).get(2)" custom="org.jsoup.nodes.Element.NodeList,org.jsoup.nodes.Document" />
|
<watch expression="((org.jsoup.nodes.Element.NodeList)((Document)doc).childNodes).get(2)" custom="org.jsoup.nodes.Element.NodeList,org.jsoup.nodes.Document" />
|
||||||
|
|||||||
95
README.md
95
README.md
@@ -1,47 +1,72 @@
|
|||||||
# BlogShot
|
# BlogShot
|
||||||
A bot that automatically polls the newest blogpost from [Hytale News Tab](https://www.hytale.com/news) and posts a message into servers if there is a new one.
|
A bot that automatically polls the newest blogpost from [Hytale News Tab](https://www.hytale.com/news) and posts a message into servers if there is a new one.
|
||||||
## Setup
|
## Add to your server
|
||||||
Okay, this isn't really meant for you to setup, if you want it though it first is easier to just dm me on Twitter [@tale_talk](https://twitter.com/tale_talk) so I can add you to the server list.
|
Click [this](https://discord.com/api/oauth2/authorize?client_id=743447329901641799&permissions=150528&scope=bot) link to invite
|
||||||
If you *really* want to set it up yourself, fine.
|
the bot to your server. Please note that only people with *Administrator* permission will be able to
|
||||||
1. first go to the release tab, download the jar, and put it in a folder
|
configure it.
|
||||||
2. Add two files in the root of the repo, an `admin.json` and a `servers.json`.
|
|
||||||
Add your Discord ID (not name), Bot token, and update frequency to the `admin.json`:
|
You can type `%!info` to get an overview over all available commands.
|
||||||
```json
|
## Commands
|
||||||
{"adminId": 12345678910,"token": "AOGH@(AKnjsfjiJijaig3ijgG92jaij","updateMs":30000}
|
|
||||||
```
|
| **Command** | **Arguments** | **Info** |
|
||||||
3. add an empty array to your `servers.json`
|
|------------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------|
|
||||||
```json
|
| %!add | | Add current channel to the notified list |
|
||||||
[]
|
| %!remove | | Remove current channel to the notified list |
|
||||||
```
|
| %!publish | on | off | [Community|Partner|Verified only] Auto publish the message if in an announcement channel |
|
||||||
Not sure, but it might be that multiline JSON doesn't work.
|
| %!ping | none | everyone | roleName | What role to ping |
|
||||||
|
| %!setMessage | message | Set a custom message when a blogpost arrives |
|
||||||
|
| %!resetMessage | | Reset the custom message to none |
|
||||||
|
| %!serviceChannel | add | remove | Add/remove channel from service notification list |
|
||||||
|
| %!publishMessage | on | off | [Community|Partner|Verified only] Auto publish the custom message if in an announcement channel |
|
||||||
|
| %!info | | Show an overview about all channels registered on this server |
|
||||||
|
| %!report | Your message | Report an issue to the Bot Admin (this will share your user name so they can contact you) |
|
||||||
|
| %!help | | Show a help dialog with all these commands |
|
||||||
|
|
||||||
|
## Self Hosting
|
||||||
|
Okay, this isn't really meant for you to setup, but if you *really* want to set it up yourself, fine.
|
||||||
|
Go to the release tab, download the jar, and put it in a folder.
|
||||||
|
|
||||||
|
Start the server with `java -jar [server-file-name]` If you put in everything correctly,
|
||||||
|
the bot should message you on Discord.
|
||||||
|
|
||||||
|
*Note:* You need to invite the bot into a server before it can message you.
|
||||||
|
|
||||||
|
Run it once (it should crash or print an error), so `admin.json`, `servers.json` and `service_channels.json`
|
||||||
|
are being created.
|
||||||
|
Add your Discord ID `adminId` (not name), Bot token `token`, and update frequency `updateMs` to the `admin.json`,
|
||||||
|
optionally you can add your own messages for when the bot is looking and when it can't reach Hytale Servers.
|
||||||
|
|
||||||
|
If you verified that everything works correctly, you can start the server in the background, on Linux that is
|
||||||
|
`nohup java -Xmx1024m -jar [server-file-name]`. To stop it you can either type `!stop` in the Admin Console (Discord PM) or
|
||||||
|
if the bot is unresponsive the the PID of it through `ps -ef` and `kill [pid]`
|
||||||
|
|
||||||
|
I'm not 100% certain how much RAM the bot needs, default is typically `-Xmx256m`, and that lead to some issues, `-Xmx512m` is probably plenty, because my server has
|
||||||
|
tons of unused ram I set it to `-Xmx2048m`, just try and look what works for you.
|
||||||
|
|
||||||
## Compiling yourself
|
## Compiling yourself
|
||||||
I developed it under Windows, and had some trouble compiling it on Linux. You mileage may vary.
|
I developed it under Windows, and had some trouble compiling it on Linux. You mileage may vary.
|
||||||
|
|
||||||
## Admin commands
|
## Admin commands
|
||||||
|
|
||||||
Start the server with `java -jar [server-file-name]` If you put in everything correctly, the bot should message you on Discord.
|
| **Command** | **Arguments** | **Info** |
|
||||||
### Adding Servers
|
|------------------|-------|---------------------|
|
||||||
```
|
| !info | | Show all registered channels and servers. |
|
||||||
%!addChannel [channelID] [roleID/everyone]
|
| !stop | | Stop the server (useful when running in `nohup`) |
|
||||||
```
|
| !serviceMessage | message | Send a service message to all registered channels |
|
||||||
Second argument is optional.
|
| !fakeUpdate | | Cause a fake update (**WARNING**: This will show on **ALL** registered servers) |
|
||||||
### Cause a fake update (test if it works)
|
| !refreshList | | Refresh servers and service channels from disk (if you manually edit the JSON files) |
|
||||||
```
|
| !removeInactive | | Remove inactive channels |
|
||||||
%!fakeUpdate
|
| !help | | Show a help dialog with all these commands |
|
||||||
```
|
|
||||||
### Stop the server from within Discord
|
|
||||||
```
|
|
||||||
%!stop
|
|
||||||
```
|
|
||||||
### Show servers, channels and roles
|
|
||||||
```
|
|
||||||
%!info
|
|
||||||
```
|
|
||||||
|
|
||||||
These commands will work in every channel, but will be ignored if they don't come from you, however the bot will always respond in a private message.
|
These commands will only work by private messaging the bot (and will be ignored if they don't
|
||||||
It will also print errors directly in a Discord private message.
|
come from the admin registered in the `admin.json`.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
Mainly reaction roles for convenience, self setup on invite to server, Twitter integration.
|
Mainly reaction roles for convenience, Twitter integration to either be even faster or to brag how much faster
|
||||||
|
we were over the official Hytale Twitter.
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
Thanks to [Forcellrus](https://github.com/Forcellrus/Discord-Auto-Publisher) for discovering a way to auto publish messages
|
||||||
|
in news channels
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'de.wulkanat'
|
group 'de.wulkanat'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.4.3'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
27
src/main/java/Inaccessibles.java
Normal file
27
src/main/java/Inaccessibles.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import net.dv8tion.jda.internal.requests.Method;
|
||||||
|
import net.dv8tion.jda.internal.requests.Route;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
|
public class Inaccessibles {
|
||||||
|
/**
|
||||||
|
* This is private by default
|
||||||
|
*
|
||||||
|
* @param method look
|
||||||
|
* @param route somewhere
|
||||||
|
* @return else
|
||||||
|
*/
|
||||||
|
public static Route getRoute(Method method, String route) {
|
||||||
|
try {
|
||||||
|
Constructor<?> constructor = Route.class.getDeclaredConstructor(Method.class, String.class);
|
||||||
|
constructor.setAccessible(true);
|
||||||
|
return (Route) constructor.newInstance(method, route);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toUnsignedString(long num) {
|
||||||
|
return Long.toUnsignedString(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import kotlinx.serialization.json.Json
|
|||||||
import kotlinx.serialization.json.JsonConfiguration
|
import kotlinx.serialization.json.JsonConfiguration
|
||||||
import net.dv8tion.jda.api.EmbedBuilder
|
import net.dv8tion.jda.api.EmbedBuilder
|
||||||
import net.dv8tion.jda.api.JDA
|
import net.dv8tion.jda.api.JDA
|
||||||
|
import net.dv8tion.jda.api.entities.Activity
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed
|
import net.dv8tion.jda.api.entities.MessageEmbed
|
||||||
import net.dv8tion.jda.api.entities.User
|
import net.dv8tion.jda.api.entities.User
|
||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
@@ -12,12 +13,16 @@ object Admin {
|
|||||||
val userId: Long
|
val userId: Long
|
||||||
val token: String
|
val token: String
|
||||||
val updateMs: Long
|
val updateMs: Long
|
||||||
|
val message: String
|
||||||
|
val offlineMessage: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val admin = Json(JsonConfiguration.Stable).parse(AdminFile.serializer(), ADMIN_FILE.readText())
|
val admin = Json(JsonConfiguration.Stable).parse(AdminFile.serializer(), ADMIN_FILE.readText())
|
||||||
userId = admin.adminId
|
userId = admin.adminId
|
||||||
token = admin.token
|
token = admin.token
|
||||||
updateMs = admin.updateMs
|
updateMs = admin.updateMs
|
||||||
|
message = admin.watchingMessage
|
||||||
|
offlineMessage = admin.offlineMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
var jda: JDA? = null
|
var jda: JDA? = null
|
||||||
@@ -31,7 +36,7 @@ object Admin {
|
|||||||
kotlin.io.println("Connected to ${admin!!.name}. No further errors will be printed here.")
|
kotlin.io.println("Connected to ${admin!!.name}. No further errors will be printed here.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var admin: User? = null
|
var admin: User? = null
|
||||||
|
|
||||||
fun println(msg: String) {
|
fun println(msg: String) {
|
||||||
sendDevMessage(
|
sendDevMessage(
|
||||||
@@ -53,14 +58,21 @@ object Admin {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun error(msg: String, error: Exception) {
|
fun error(msg: String, error: String, author: User? = null) {
|
||||||
sendDevMessage(
|
sendDevMessage(
|
||||||
EmbedBuilder()
|
EmbedBuilder()
|
||||||
.setTitle(msg)
|
.setTitle(msg)
|
||||||
.setDescription(error.message)
|
.setDescription(error)
|
||||||
.setColor(Color.RED)
|
.setColor(Color.RED)
|
||||||
|
.run {
|
||||||
|
if (author == null) {
|
||||||
|
this
|
||||||
|
} else {
|
||||||
|
this.setAuthor(author.asTag, author.avatarUrl, author.avatarUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
.build()
|
.build()
|
||||||
, "$msg\n\n${error.message}"
|
, "$msg\n\n${error}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +101,12 @@ object Admin {
|
|||||||
sendDevMessage(
|
sendDevMessage(
|
||||||
EmbedBuilder()
|
EmbedBuilder()
|
||||||
.setTitle("Now watching for new Hytale Blogposts every ${updateMs / 1000}s")
|
.setTitle("Now watching for new Hytale Blogposts every ${updateMs / 1000}s")
|
||||||
.setDescription(Channels.getServerNames().joinToString("\n"))
|
.setDescription("""
|
||||||
|
${Channels.getServerNames().joinToString("\n")}
|
||||||
|
|
||||||
|
**_Service Channels_**
|
||||||
|
${Channels.getServiceChannelServers().joinToString("\n")}
|
||||||
|
""".trimIndent())
|
||||||
.setColor(Color.GREEN)
|
.setColor(Color.GREEN)
|
||||||
.build(),
|
.build(),
|
||||||
"Now watching for new Hytale BlogPosts"
|
"Now watching for new Hytale BlogPosts"
|
||||||
@@ -101,17 +118,17 @@ object Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun senDevMessageBlocking(messageEmbed: MessageEmbed, fallback: String) {
|
private fun senDevMessageBlocking(messageEmbed: MessageEmbed, fallback: String) {
|
||||||
|
admin = jda!!.retrieveUserById(userId).complete()
|
||||||
val devChannel = admin?.openPrivateChannel() ?: kotlin.run {
|
val devChannel = admin?.openPrivateChannel() ?: kotlin.run {
|
||||||
kotlin.io.println(fallback)
|
kotlin.io.println(fallback)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
devChannel.queue {
|
devChannel.complete()
|
||||||
it.sendMessage(messageEmbed).complete()
|
.sendMessage(messageEmbed).complete()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendDevMessage(messageEmbed: MessageEmbed, fallback: String) {
|
fun sendDevMessage(messageEmbed: MessageEmbed, fallback: String) {
|
||||||
val devChannel = admin?.openPrivateChannel() ?: kotlin.run {
|
val devChannel = admin?.openPrivateChannel() ?: kotlin.run {
|
||||||
kotlin.io.println(fallback)
|
kotlin.io.println(fallback)
|
||||||
return
|
return
|
||||||
|
|||||||
91
src/main/kotlin/de/wulkanat/AdminCli.kt
Normal file
91
src/main/kotlin/de/wulkanat/AdminCli.kt
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
package de.wulkanat
|
||||||
|
|
||||||
|
import de.wulkanat.model.BlogPostPreview
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
|
import de.wulkanat.web.SiteWatcher
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder
|
||||||
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent
|
||||||
|
import java.awt.Color
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
class AdminCli : ListenerAdapter() {
|
||||||
|
val prefix = "!"
|
||||||
|
|
||||||
|
override fun onPrivateMessageReceived(event: PrivateMessageReceivedEvent) {
|
||||||
|
val msg = event.message.contentRaw
|
||||||
|
if (event.author.idLong != Admin.userId ||
|
||||||
|
!msg.startsWith(prefix)
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val command = Regex("[^\\s`]+|`[^`]*`").findAll(msg.removePrefix("!")).toList()
|
||||||
|
|
||||||
|
when (command[0].value) {
|
||||||
|
"stop" -> exitProcess(1)
|
||||||
|
"fakeUpdate" -> {
|
||||||
|
SiteWatcher.newestBlog = BlogPostPreview(
|
||||||
|
title = "FakePost",
|
||||||
|
imgUrl = "",
|
||||||
|
fullPostUrl = "",
|
||||||
|
author = "wulkanat",
|
||||||
|
date = "now",
|
||||||
|
description = "Lorem Ipsum"
|
||||||
|
)
|
||||||
|
|
||||||
|
Admin.println("Posting on next update cycle.")
|
||||||
|
}
|
||||||
|
"info" -> {
|
||||||
|
Admin.info()
|
||||||
|
}
|
||||||
|
"serviceMessage" -> {
|
||||||
|
if (command.size != 3) {
|
||||||
|
Admin.println("Enclose message and title in backticks (`)")
|
||||||
|
} else {
|
||||||
|
Channels.sendServiceMessage(command[1].value.trim('`'), command[2].value.trim('`'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"refreshList" -> {
|
||||||
|
Channels.channels = Channels.refreshChannelsFromDisk()
|
||||||
|
Channels.serviceChannels = Channels.refreshServiceChannelsFromDisk()
|
||||||
|
Admin.info()
|
||||||
|
}
|
||||||
|
"removeInactive" -> {
|
||||||
|
Channels.channels.removeAll { channel ->
|
||||||
|
Channels.testServerId(channel.id) ?: run {
|
||||||
|
Admin.println("Removed ${channel.id}")
|
||||||
|
null
|
||||||
|
} == null
|
||||||
|
}
|
||||||
|
Admin.info()
|
||||||
|
Channels.saveChannels()
|
||||||
|
}
|
||||||
|
"help" -> {
|
||||||
|
event.message.channel.sendMessage(
|
||||||
|
EmbedBuilder()
|
||||||
|
.setTitle("Help")
|
||||||
|
.setColor(Color.YELLOW)
|
||||||
|
.setAuthor(Admin.admin?.name, Admin.admin?.avatarUrl, Admin.admin?.avatarUrl)
|
||||||
|
.setDescription(
|
||||||
|
"""
|
||||||
|
**${prefix}stop**
|
||||||
|
Stop the bot
|
||||||
|
**${prefix}fakeUpdate**
|
||||||
|
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
|
||||||
|
**${prefix}serviceMessage [title] [message]**
|
||||||
|
Show a service message (update info etc) to all registered service channels
|
||||||
|
**${prefix}refreshList**
|
||||||
|
Refresh server list from disk
|
||||||
|
**${prefix}removeInactive**
|
||||||
|
Remove inactive channels
|
||||||
|
**${prefix}help**
|
||||||
|
Show this message
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
).queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package de.wulkanat
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
|
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
|
||||||
|
|
||||||
class Bot : ListenerAdapter() {
|
|
||||||
override fun onMessageReceived(event: MessageReceivedEvent) {
|
|
||||||
val message = event.message
|
|
||||||
|
|
||||||
if (message.contentRaw == "!ping") {
|
|
||||||
val channel = message.channel
|
|
||||||
val time = System.currentTimeMillis()
|
|
||||||
|
|
||||||
channel.sendMessage("Pong!")
|
|
||||||
.queue {
|
|
||||||
it.editMessageFormat("Pong: %d ms", System.currentTimeMillis() - time)
|
|
||||||
.queue()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +1,88 @@
|
|||||||
package de.wulkanat
|
package de.wulkanat
|
||||||
|
|
||||||
import kotlinx.serialization.json.Json
|
import de.wulkanat.extensions.crosspost
|
||||||
import kotlinx.serialization.json.JsonConfiguration
|
|
||||||
import kotlinx.serialization.list
|
import kotlinx.serialization.list
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder
|
||||||
import net.dv8tion.jda.api.JDA
|
import net.dv8tion.jda.api.JDA
|
||||||
import net.dv8tion.jda.api.Permission
|
import net.dv8tion.jda.api.Permission
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed
|
import net.dv8tion.jda.api.entities.MessageEmbed
|
||||||
import net.dv8tion.jda.api.entities.TextChannel
|
import net.dv8tion.jda.api.entities.TextChannel
|
||||||
|
import java.awt.Color
|
||||||
|
|
||||||
object Channels {
|
object Channels {
|
||||||
var jda: JDA? = null
|
var jda: JDA? = null
|
||||||
val json = Json(JsonConfiguration.Stable)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of (ServerID, ChannelID)
|
* List of (ServerID, ChannelID)
|
||||||
*/
|
*/
|
||||||
val channels: MutableList<DiscordChannel> =
|
var channels: MutableList<DiscordChannel> = refreshChannelsFromDisk()
|
||||||
json.parse(DiscordChannel.serializer().list, SERVERS_FILE.readText()).toMutableList()
|
var serviceChannels: MutableList<ServiceChannel> = refreshServiceChannelsFromDisk()
|
||||||
|
|
||||||
fun sentToAll(messageEmbed: MessageEmbed) {
|
fun sentToAll(messageEmbed: MessageEmbed) {
|
||||||
if (jda == null)
|
if (jda == null)
|
||||||
return
|
return
|
||||||
|
|
||||||
for (channel_pair in channels) {
|
for (channel_pair in channels) {
|
||||||
val channel = jda!!.getTextChannelById(channel_pair.id) ?: continue
|
try {
|
||||||
|
val channel = jda!!.getTextChannelById(channel_pair.id) ?: continue
|
||||||
|
val customMessage = channel_pair.message?.message ?: ""
|
||||||
|
|
||||||
if (channel_pair.mentionedRole != null) {
|
if (channel_pair.mentionedRole != null) {
|
||||||
val message = if (channel_pair.mentionedRole == "everyone") {
|
val message = if (channel_pair.mentionedRole == "everyone") {
|
||||||
"New Blogpost @everyone"
|
"@everyone $customMessage"
|
||||||
} else {
|
} else {
|
||||||
"New Blogpost <@&${channel_pair.mentionedRole}>"
|
"<@&${channel_pair.mentionedRole}> $customMessage"
|
||||||
|
}
|
||||||
|
channel.sendMessage(message).queue {
|
||||||
|
if (channel_pair.message?.pushAnnouncement == true) {
|
||||||
|
it.crosspost().queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (channel_pair.message != null) {
|
||||||
|
channel.sendMessage(customMessage).queue {
|
||||||
|
if (channel_pair.message?.pushAnnouncement == true) {
|
||||||
|
it.crosspost().queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
channel.sendMessage(message).queue()
|
channel.sendMessage(messageEmbed).queue {
|
||||||
|
if (channel_pair.autoPublish) {
|
||||||
|
it.crosspost().queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Admin.error("Error in server ${channel_pair.id}", e.message ?: e.localizedMessage)
|
||||||
}
|
}
|
||||||
channel.sendMessage(messageEmbed).queue()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sendServiceMessage(title: String, message: String) {
|
||||||
|
val serviceMessage = EmbedBuilder()
|
||||||
|
.setTitle(title)
|
||||||
|
.setDescription(message)
|
||||||
|
.setColor(Color.WHITE)
|
||||||
|
.setAuthor(Admin.admin?.name, Admin.admin?.avatarUrl, Admin.admin?.avatarUrl)
|
||||||
|
.setFooter("This was sent by a human.")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
for (channelInfo in serviceChannels) {
|
||||||
|
val channel = jda!!.getTextChannelById(channelInfo.id)
|
||||||
|
|
||||||
|
channel?.sendMessage(serviceMessage)?.queue()
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin.println("Service message distributed to ${serviceChannels.size} channels.")
|
||||||
|
Admin.sendDevMessage(serviceMessage, """
|
||||||
|
***************
|
||||||
|
SERVICE MESSAGE
|
||||||
|
|
||||||
|
$title
|
||||||
|
-------
|
||||||
|
$message
|
||||||
|
***************
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
|
|
||||||
fun checkEveryonePermission() {
|
fun checkEveryonePermission() {
|
||||||
for (channel_pair in channels) {
|
for (channel_pair in channels) {
|
||||||
val channel = jda!!.getTextChannelById(channel_pair.id) ?: continue
|
val channel = jda!!.getTextChannelById(channel_pair.id) ?: continue
|
||||||
@@ -52,25 +98,51 @@ object Channels {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getServerNames(): List<String> {
|
fun refreshChannelsFromDisk(): MutableList<DiscordChannel> {
|
||||||
|
return json.parse(
|
||||||
|
DiscordChannel.serializer().list, (SERVERS_FILE).readText()
|
||||||
|
).toMutableList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refreshServiceChannelsFromDisk(): MutableList<ServiceChannel> {
|
||||||
|
return json.parse(
|
||||||
|
ServiceChannel.serializer().list, (SERVICE_CHANNELS_FILE).readText()
|
||||||
|
).toMutableList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServerNames(server: Long? = null): List<String> {
|
||||||
if (jda == null)
|
if (jda == null)
|
||||||
return listOf()
|
return listOf()
|
||||||
|
|
||||||
return channels.map {
|
return channels.filter { server == null || (jda!!.getTextChannelById(it.id)?.guild?.idLong == server) }.map {
|
||||||
val channel = jda!!.getTextChannelById(it.id)
|
val channel = jda!!.getTextChannelById(it.id)
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
Admin.warning("Channel ${it.id} is no longer active!")
|
Admin.warning("Channel ${it.id} is no longer active!")
|
||||||
return@map "**${it.id}** *(inactive)*"
|
return@map "**${it.id}** *(inactive)*"
|
||||||
}
|
}
|
||||||
|
|
||||||
val role = if (it.mentionedRole == null) {
|
val role = when (it.mentionedRole) {
|
||||||
""
|
null -> ""
|
||||||
} else if (it.mentionedRole == "everyone") {
|
"everyone" -> " @everyone"
|
||||||
" @everyone"
|
else -> " @${channel.guild.getRoleById(it.mentionedRole ?: "")?.name}"
|
||||||
} else {
|
|
||||||
" @${channel.guild.getRoleById(it.mentionedRole)?.name}"
|
|
||||||
}
|
}
|
||||||
"**${channel.guild.name}**\n#${channel.name}${role}"
|
val publish = if (it.autoPublish) " (publish)" else ""
|
||||||
|
"**${channel.guild.name}** #${channel.name}${role}${publish}${if (it.message == null) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"\n*${it.message!!.message}*${if (it.message!!.pushAnnouncement) " (publish)" else ""}"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServiceChannelServers(server: Long? = null): List<String> {
|
||||||
|
if (jda == null)
|
||||||
|
return listOf()
|
||||||
|
|
||||||
|
return serviceChannels.filter { server == null || (jda!!.getTextChannelById(it.id)?.guild?.idLong == server) }.map {
|
||||||
|
val channel = jda!!.getTextChannelById(it.id)
|
||||||
|
"**${channel?.guild?.name ?: it.id}** #${channel?.name ?: "(inactive)"}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,16 +150,28 @@ object Channels {
|
|||||||
return jda?.getTextChannelById(id)
|
return jda?.getTextChannelById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addChannel(id: Long, role: String?) {
|
fun addChannel(id: Long, role: String?): DiscordChannel? {
|
||||||
channels.add(DiscordChannel(id, role))
|
if (channels.find { it.id == id } != null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val out = DiscordChannel(id, role)
|
||||||
|
channels.add(out)
|
||||||
saveChannels()
|
saveChannels()
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveChannels() {
|
fun saveChannels() {
|
||||||
SERVERS_FILE.writeText(
|
SERVERS_FILE.writeText(
|
||||||
json.stringify(
|
json.stringify(
|
||||||
DiscordChannel.serializer().list,
|
DiscordChannel.serializer().list,
|
||||||
channels
|
channels
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
SERVICE_CHANNELS_FILE.writeText(
|
||||||
|
json.stringify(
|
||||||
|
ServiceChannel.serializer().list,
|
||||||
|
serviceChannels
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package de.wulkanat
|
|
||||||
|
|
||||||
import de.wulkanat.model.BlogPostPreview
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
|
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
|
||||||
import de.wulkanat.web.SiteWatcher
|
|
||||||
import kotlin.system.exitProcess
|
|
||||||
|
|
||||||
class Cli : ListenerAdapter() {
|
|
||||||
override fun onMessageReceived(event: MessageReceivedEvent) {
|
|
||||||
val msg = event.message.contentRaw
|
|
||||||
if (event.author.idLong != Admin.userId ||
|
|
||||||
!msg.startsWith("%!")
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val command = msg.removePrefix("%!").split(" ")
|
|
||||||
|
|
||||||
try {
|
|
||||||
when (command[0]) {
|
|
||||||
"stop" -> exitProcess(1)
|
|
||||||
"fakeUpdate" -> {
|
|
||||||
SiteWatcher.newestBlog = BlogPostPreview(
|
|
||||||
title = "FakePost",
|
|
||||||
imgUrl = "",
|
|
||||||
fullPostUrl = "",
|
|
||||||
author = "wulkanat",
|
|
||||||
date = "now",
|
|
||||||
description = "Lorem Ipsum"
|
|
||||||
)
|
|
||||||
|
|
||||||
Admin.println("Posting on next update cycle.")
|
|
||||||
}
|
|
||||||
"addChannel" -> {
|
|
||||||
val channel = command[1].toLong()
|
|
||||||
var role: String? = null
|
|
||||||
if (command.size == 3) {
|
|
||||||
role = command[2]
|
|
||||||
}
|
|
||||||
val serverChannel = Channels.testServerId(channel)
|
|
||||||
val roleName = serverChannel?.guild?.getRoleById(role ?: "")
|
|
||||||
|
|
||||||
if (serverChannel != null) {
|
|
||||||
if (roleName != null || role == null || role == "everyone") {
|
|
||||||
Channels.addChannel(channel, role)
|
|
||||||
Admin.println("Added server '${serverChannel.name}' for role '${roleName ?: role}'")
|
|
||||||
} else {
|
|
||||||
Admin.warning("Unknown Role ID")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Admin.warning("Unknown Channel ID")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"info" -> {
|
|
||||||
Admin.info()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,43 @@
|
|||||||
package de.wulkanat
|
package de.wulkanat
|
||||||
|
|
||||||
|
import de.wulkanat.extensions.ensureExists
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonConfiguration
|
||||||
|
import kotlinx.serialization.list
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DiscordChannel(
|
data class DiscordChannel(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val mentionedRole: String? = null
|
var mentionedRole: String? = null,
|
||||||
|
var autoPublish: Boolean = false,
|
||||||
|
var message: CustomMessage? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ServiceChannel(
|
||||||
|
val id: Long
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CustomMessage(
|
||||||
|
var message: String,
|
||||||
|
var pushAnnouncement: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AdminFile(
|
data class AdminFile(
|
||||||
val adminId: Long,
|
val adminId: Long = 12345,
|
||||||
val token: String,
|
val token: String = "12345",
|
||||||
val updateMs: Long
|
val updateMs: Long = 30000,
|
||||||
|
val watchingMessage: String = "for new Blogposts",
|
||||||
|
val offlineMessage: String = "CONNECTION FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
val SERVERS_FILE = File("servers.json")
|
val json = Json(JsonConfiguration.Stable)
|
||||||
val ADMIN_FILE = File("admin.json")
|
|
||||||
|
val SERVERS_FILE = File("servers.json").ensureExists(json.stringify(DiscordChannel.serializer().list, listOf()))
|
||||||
|
val SERVICE_CHANNELS_FILE =
|
||||||
|
File("service_channels.json").ensureExists(json.stringify(ServiceChannel.serializer().list, listOf()))
|
||||||
|
val ADMIN_FILE = File("admin.json").ensureExists(json.stringify(AdminFile.serializer(), AdminFile()))
|
||||||
|
|||||||
17
src/main/kotlin/de/wulkanat/DiscordRpc.kt
Normal file
17
src/main/kotlin/de/wulkanat/DiscordRpc.kt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package de.wulkanat
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.JDA
|
||||||
|
import net.dv8tion.jda.api.entities.Activity
|
||||||
|
|
||||||
|
object DiscordRpc {
|
||||||
|
var jda: JDA? = null
|
||||||
|
|
||||||
|
fun updatePresence(available: Boolean) {
|
||||||
|
// jda ?: return
|
||||||
|
|
||||||
|
// jda!!.presence.activity = Activity.watching(if (available) Admin.message else Admin.offlineMessage)
|
||||||
|
// jda!!.presence.isIdle = !available
|
||||||
|
// noop
|
||||||
|
if (available) Admin.println("Back online") else Admin.error("Gone offline", "Can't reach Hytale server")
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/main/kotlin/de/wulkanat/ErrorHandler.kt
Normal file
10
src/main/kotlin/de/wulkanat/ErrorHandler.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package de.wulkanat
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.ExceptionEvent
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
|
|
||||||
|
class ErrorHandler : ListenerAdapter() {
|
||||||
|
override fun onException(event: ExceptionEvent) {
|
||||||
|
Admin.error(event.cause.message ?: event.cause.localizedMessage, event.cause.stackTrace.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,25 +7,28 @@ import de.wulkanat.web.SiteWatcher
|
|||||||
import kotlin.concurrent.timer
|
import kotlin.concurrent.timer
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
// TODO: move toke into file
|
|
||||||
val builder = JDABuilder.createLight(
|
val builder = JDABuilder.createLight(
|
||||||
Admin.token,
|
Admin.token,
|
||||||
GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES)
|
GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES)
|
||||||
.addEventListeners(Bot())
|
.setActivity(Activity.watching(Admin.message))
|
||||||
.setActivity(Activity.watching("for new Blogposts"))
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
builder.addEventListener(Cli())
|
builder.addEventListener(AdminCli())
|
||||||
|
builder.addEventListener(ErrorHandler())
|
||||||
|
builder.addEventListener(OwnerCli())
|
||||||
builder.awaitReady()
|
builder.awaitReady()
|
||||||
|
|
||||||
Channels.jda = builder
|
Channels.jda = builder
|
||||||
Admin.jda = builder
|
Admin.jda = builder
|
||||||
|
DiscordRpc.jda = builder
|
||||||
Admin.info()
|
Admin.info()
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(object : Thread() {
|
Runtime.getRuntime().addShutdownHook(object : Thread() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
println("Shutting down...")
|
println("Shutting down...")
|
||||||
Admin.printlnBlocking("Shutting down")
|
println("Sending shutdown notice to Admin, waiting 5s...")
|
||||||
|
Admin.println("Shutting down")
|
||||||
|
sleep(5000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
215
src/main/kotlin/de/wulkanat/OwnerCli.kt
Normal file
215
src/main/kotlin/de/wulkanat/OwnerCli.kt
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
package de.wulkanat
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder
|
||||||
|
import net.dv8tion.jda.api.Permission
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
|
import java.awt.Color
|
||||||
|
|
||||||
|
class OwnerCli : ListenerAdapter() {
|
||||||
|
private val prefix = "%!"
|
||||||
|
|
||||||
|
override fun onMessageReceived(event: MessageReceivedEvent) {
|
||||||
|
val msg = event.message.contentRaw
|
||||||
|
// Only accept admin requests
|
||||||
|
if (event.message.member?.hasPermission(Permission.ADMINISTRATOR) != true || !msg.startsWith(prefix)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val command = msg.removePrefix(prefix).split(Regex("\\s+"))
|
||||||
|
val channelId = event.message.channel.idLong
|
||||||
|
|
||||||
|
when (command.first()) {
|
||||||
|
"add" -> {
|
||||||
|
val result = Channels.addChannel(channelId, null)
|
||||||
|
if (result == null) {
|
||||||
|
event.message.channel.sendMessage("Already added.").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Added.").queue()
|
||||||
|
Admin.info()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"remove" -> {
|
||||||
|
val result = Channels.channels.removeAll { it.id == channelId }
|
||||||
|
Channels.saveChannels()
|
||||||
|
if (result) {
|
||||||
|
event.message.channel.sendMessage("Removed.").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("This channel is not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"publish" -> {
|
||||||
|
val result = Channels.channels.find { it.id == channelId }
|
||||||
|
if (result != null) {
|
||||||
|
if (command.size > 1 && listOf("on", "off").contains(command[1])) {
|
||||||
|
result.autoPublish = command[1] == "on"
|
||||||
|
Channels.saveChannels()
|
||||||
|
|
||||||
|
event.message.channel.sendMessage("Auto publish is now ${command[1]}").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Usage: `${prefix}publish [on|off]`")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"ping" -> {
|
||||||
|
val result = Channels.channels.find { it.id == channelId }
|
||||||
|
if (result != null) {
|
||||||
|
if (command.size > 1) {
|
||||||
|
val roles = event.message.guild.getRolesByName(command[1], false)
|
||||||
|
result.mentionedRole = when {
|
||||||
|
command[1] == "everyone" -> {
|
||||||
|
event.message.channel.sendMessage("Now pinging everyone.").queue()
|
||||||
|
"everyone"
|
||||||
|
}
|
||||||
|
command[1] == "none" -> {
|
||||||
|
event.message.channel.sendMessage("Now pinging none.").queue()
|
||||||
|
null
|
||||||
|
}
|
||||||
|
roles.firstOrNull() != null -> {
|
||||||
|
event.message.channel.sendMessage("Now pinging ${roles.first().name}").queue()
|
||||||
|
roles.first().id
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
event.message.channel.sendMessage("Unknown role.").queue()
|
||||||
|
result.mentionedRole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Channels.saveChannels()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Usage: `${prefix}ping [everyone|none|roleName]`")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel is not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"setMessage" -> {
|
||||||
|
val result = Channels.channels.find { it.id == channelId }
|
||||||
|
if (result != null) {
|
||||||
|
if (command.size > 1) {
|
||||||
|
val message = event.message.contentRaw.removePrefix("${prefix}setMessage").trim()
|
||||||
|
result.message = CustomMessage(message)
|
||||||
|
Channels.saveChannels()
|
||||||
|
event.message.channel.sendMessage("Set `$message` as message.").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Usage: `${prefix}setMessage [message]`")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel is not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"resetMessage" -> {
|
||||||
|
val result = Channels.channels.find { it.id == channelId }
|
||||||
|
if (result != null) {
|
||||||
|
result.message = null
|
||||||
|
Channels.saveChannels()
|
||||||
|
event.message.channel.sendMessage("Reset to no message.").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel is not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"serviceChannel" -> {
|
||||||
|
if (command.size > 1 && listOf("add", "remove").contains(command[1])) {
|
||||||
|
if (command[1] == "add") {
|
||||||
|
if (Channels.serviceChannels.find { it.id == channelId } != null) {
|
||||||
|
event.message.channel.sendMessage("Already a service channel.").queue()
|
||||||
|
} else {
|
||||||
|
Channels.serviceChannels.add(ServiceChannel(channelId))
|
||||||
|
Channels.saveChannels()
|
||||||
|
event.message.channel.sendMessage("Added as service channel.").queue()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage(
|
||||||
|
if (Channels.serviceChannels.removeAll { it.id == channelId }) "Channel removed."
|
||||||
|
else "Not a service channel."
|
||||||
|
).queue()
|
||||||
|
}
|
||||||
|
Channels.saveChannels()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Usage: `${prefix}serviceChannel [add|remove]`")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
"publishMessage" -> {
|
||||||
|
val result = Channels.channels.find { it.id == channelId }
|
||||||
|
if (result != null) {
|
||||||
|
if (result.message != null) {
|
||||||
|
if (command.size > 1 && listOf("on", "off").contains(command[1])) {
|
||||||
|
result.message?.pushAnnouncement = command[1] == "on"
|
||||||
|
Channels.saveChannels()
|
||||||
|
|
||||||
|
event.message.channel.sendMessage("Auto publish (message) is now ${command[1]}").queue()
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Usage: `${prefix}publishMessage [on|off]`")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel has no custom message.").queue()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.message.channel.sendMessage("Channel not registered.").queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"info" -> {
|
||||||
|
event.message.channel.sendMessage(
|
||||||
|
EmbedBuilder()
|
||||||
|
.setTitle("Server overview")
|
||||||
|
.setColor(Color.GREEN)
|
||||||
|
.setDescription("""
|
||||||
|
${Channels.getServerNames(event.message.guild.idLong).joinToString("\n")}
|
||||||
|
|
||||||
|
**_Service Channels_**
|
||||||
|
${Channels.getServiceChannelServers(event.message.guild.idLong).joinToString("\n")}
|
||||||
|
""".trimIndent())
|
||||||
|
.setAuthor(Admin.admin?.name, Admin.admin?.avatarUrl, Admin.admin?.avatarUrl)
|
||||||
|
.build()
|
||||||
|
).queue()
|
||||||
|
}
|
||||||
|
"report" -> {
|
||||||
|
val errorReport = event.message.contentRaw.removePrefix("${prefix}report")
|
||||||
|
Admin.error(event.message.guild.name, errorReport, event.author)
|
||||||
|
event.message.channel.sendMessage(
|
||||||
|
EmbedBuilder()
|
||||||
|
.setTitle("Error Report Received")
|
||||||
|
.setColor(Color.RED)
|
||||||
|
.setDescription(errorReport)
|
||||||
|
.setAuthor(Admin.admin?.name, Admin.admin?.avatarUrl, Admin.admin?.avatarUrl)
|
||||||
|
.build()
|
||||||
|
).queue()
|
||||||
|
}
|
||||||
|
"help" -> {
|
||||||
|
event.message.channel.sendMessage(
|
||||||
|
EmbedBuilder()
|
||||||
|
.setTitle("Help")
|
||||||
|
.setColor(Color.YELLOW)
|
||||||
|
.setAuthor(Admin.admin?.name, Admin.admin?.avatarUrl, Admin.admin?.avatarUrl)
|
||||||
|
.setDescription(
|
||||||
|
"""
|
||||||
|
**${prefix}add**
|
||||||
|
Add this channel to the notified list
|
||||||
|
**${prefix}serviceChannel [add|remove]**
|
||||||
|
Add or remove this channel to receive service message from the bot developer (recommended)
|
||||||
|
**${prefix}remove**
|
||||||
|
Remove this channel to the notified list
|
||||||
|
**${prefix}publish [on|off]**
|
||||||
|
[Community|Partner|Verified only] Auto publish the message if in an announcement channel
|
||||||
|
**${prefix}ping [none|everyone|roleName]**
|
||||||
|
What role to ping
|
||||||
|
**${prefix}setMessage [message]**
|
||||||
|
Set a custom message to show
|
||||||
|
**${prefix}resetMessage**
|
||||||
|
Reset the message
|
||||||
|
**${prefix}info**
|
||||||
|
Show an overview about all channels registered on this server
|
||||||
|
**${prefix}report**
|
||||||
|
Report an issue to the Bot Admin (this will share your user name so they can contact you)
|
||||||
|
**${prefix}help**
|
||||||
|
Show this message
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
).queue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main/kotlin/de/wulkanat/extensions/File.kt
Normal file
11
src/main/kotlin/de/wulkanat/extensions/File.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package de.wulkanat.extensions
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
fun File.ensureExists(defaultText: String? = null): File {
|
||||||
|
if (!this.exists()) {
|
||||||
|
this.createNewFile()
|
||||||
|
this.writeText(defaultText ?: return this)
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
28
src/main/kotlin/de/wulkanat/extensions/Message.kt
Normal file
28
src/main/kotlin/de/wulkanat/extensions/Message.kt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package de.wulkanat.extensions
|
||||||
|
|
||||||
|
import Inaccessibles
|
||||||
|
import net.dv8tion.jda.api.entities.Message
|
||||||
|
import net.dv8tion.jda.api.entities.MessageChannel
|
||||||
|
import net.dv8tion.jda.api.requests.restaction.MessageAction
|
||||||
|
import net.dv8tion.jda.internal.requests.Method
|
||||||
|
import net.dv8tion.jda.internal.requests.Route
|
||||||
|
import net.dv8tion.jda.internal.requests.restaction.MessageActionImpl
|
||||||
|
import net.dv8tion.jda.internal.utils.Checks
|
||||||
|
|
||||||
|
fun MessageChannel.crosspostById(messageId: String): MessageAction {
|
||||||
|
Checks.isSnowflake(messageId, "Message ID")
|
||||||
|
|
||||||
|
val route = CROSSPOST_MESSAGE.compile(id, messageId)
|
||||||
|
return MessageActionImpl(jda, route, this).append("This is not of your interest.")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Message.crosspost(): MessageAction {
|
||||||
|
val messageId = Inaccessibles.toUnsignedString(idLong)
|
||||||
|
|
||||||
|
return channel.crosspostById(messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
val CROSSPOST_MESSAGE: Route = Inaccessibles.getRoute(
|
||||||
|
Method.POST,
|
||||||
|
"channels/{channel_id}/messages/{message_id}/crosspost"
|
||||||
|
)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.wulkanat.web
|
package de.wulkanat.web
|
||||||
|
|
||||||
import de.wulkanat.Admin
|
import de.wulkanat.Admin
|
||||||
|
import de.wulkanat.DiscordRpc
|
||||||
import de.wulkanat.model.BlogPostPreview
|
import de.wulkanat.model.BlogPostPreview
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -8,10 +9,9 @@ import java.io.IOException
|
|||||||
object SiteWatcher {
|
object SiteWatcher {
|
||||||
private const val BLOG_INDEX_URL = "https://www.hytale.com/news"
|
private const val BLOG_INDEX_URL = "https://www.hytale.com/news"
|
||||||
var newestBlog: BlogPostPreview? = null
|
var newestBlog: BlogPostPreview? = null
|
||||||
|
private var siteOnline = false
|
||||||
|
|
||||||
fun hasNewBlogPost(): Boolean {
|
fun hasNewBlogPost(): Boolean {
|
||||||
Admin.silent("Updating...")
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val doc = Jsoup.connect(BLOG_INDEX_URL).get()
|
val doc = Jsoup.connect(BLOG_INDEX_URL).get()
|
||||||
val newBlog = BlogPostParser.getFistBlog(doc)
|
val newBlog = BlogPostParser.getFistBlog(doc)
|
||||||
@@ -27,11 +27,18 @@ object SiteWatcher {
|
|||||||
newestBlog = newBlog
|
newestBlog = newBlog
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Admin.error("Connection to Hytale Server failed", e)
|
Admin.error("Connection to Hytale Server failed", e.message ?: e.localizedMessage)
|
||||||
|
siteOnline = false
|
||||||
|
DiscordRpc.updatePresence(siteOnline)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!siteOnline) {
|
||||||
|
siteOnline = true
|
||||||
|
DiscordRpc.updatePresence(siteOnline)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user