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
8 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
Duga/duga-aws/src/main/kotlin/net/zomis/duga/tasks/CommentScanTask.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,7 @@ | ||
package net.zomis.duga.tasks | ||
|
||
class CommentScanTask { | ||
|
||
// Requires learning | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
Duga/duga-aws/src/main/kotlin/net/zomis/duga/tasks/DugaTask.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,5 @@ | ||
package net.zomis.duga.tasks | ||
|
||
interface DugaTask { | ||
fun perform(): Unit | ||
} |
12 changes: 12 additions & 0 deletions
12
Duga/duga-aws/src/main/kotlin/net/zomis/duga/tasks/MessageTask.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,12 @@ | ||
package net.zomis.duga.tasks | ||
|
||
import net.zomis.duga.aws.Duga | ||
import net.zomis.duga.aws.DugaMessage | ||
|
||
class MessageTask(private val room: String, private val message: String) : DugaTask { | ||
|
||
override fun perform() { | ||
Duga().send(DugaMessage(room, message)) | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
Duga/duga-aws/src/main/kotlin/net/zomis/duga/tasks/RatingDiffTask.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,9 @@ | ||
package net.zomis.duga.tasks | ||
|
||
class RatingDiffTask(private val room: String, private val site: String, private val users: List<String>) : DugaTask { | ||
|
||
override fun perform() { | ||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
Duga/duga-aws/src/main/kotlin/net/zomis/duga/tasks/UnansweredTask.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,31 @@ | ||
package net.zomis.duga.tasks | ||
|
||
import net.zomis.duga.aws.Duga | ||
import net.zomis.duga.aws.DugaMessage | ||
import net.zomis.duga.utils.StackExchangeAPI | ||
import org.slf4j.LoggerFactory | ||
import java.io.IOException | ||
|
||
class UnansweredTask(private val room: String, private val site: String, private val message: String) : DugaTask { | ||
|
||
private val logger = LoggerFactory.getLogger(javaClass) | ||
|
||
private val api = StackExchangeAPI() | ||
|
||
override fun perform() { | ||
try { | ||
val result = api.apiCall("info", site, "default") | ||
val unanswered = result["items"][0]["total_unanswered"].asInt() | ||
val total = result["items"][0]["total_questions"].asInt() | ||
val percentageAnswered = (total.toDouble() - unanswered.toDouble()) / total.toDouble() | ||
val percentageStr = String.format("%.4f", percentageAnswered * 100) | ||
var send = message | ||
send = send.replace("%unanswered%", unanswered.toString()) | ||
send = send.replace("%percentage%", percentageStr) | ||
Duga().send(DugaMessage(room, send)) | ||
} catch (e: IOException) { | ||
logger.error("Error with StackExchange API Call", e) | ||
} | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
Duga/duga-aws/src/main/kotlin/net/zomis/duga/utils/GitHubAPI.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,7 @@ | ||
package net.zomis.duga.utils | ||
|
||
class GitHubAPI { | ||
|
||
val githubAPI = System.getenv("GITHUB_API") | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../duga/net/zomis/utils/StackExchangeAPI.kt → .../net/zomis/duga/utils/StackExchangeAPI.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