Skip to content

Commit

Permalink
0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Katrix committed Nov 2, 2017
1 parent fce279a commit 8ac68b1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 17 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

AckCord is a Scala library using Akka for the Discord API. Unlike many other libraries, AckCord hides little of the underlying aspects, and gives the user much more freedom in how they want to set up their bot. Want to use a custom cache, or no cache at all, sure thing, just wire up the cache with the other actors instead of using the defaults. Have no need for the websocket part of the library? All good, just use the REST part and forget about the other parts.

While AckCord is still in active development, and no real version has been released so far, you can try AckCord by adding this to your `build.sbt` file.
While AckCord is still in active development, you can try AckCord by adding this to your `build.sbt` file.
```scala
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.Katrix-.AckCord" % "ackCord" % "master-SNAPSHOT"
libraryDependencies += "net.katsstuff" %% "ackCord" % "0.1"
```

# Usage
Expand Down Expand Up @@ -60,7 +59,7 @@ context.actorOf(GuildRouter.props(MyActor.props, Some(nonGuildHandler)), "MyActo
## Commands
You probably also want some commands for your bot. AckCord has a seperate module that makes dealing with commands easier. First add a dependency on the command module.
```scala
libraryDependencies += "com.github.Katrix-.AckCord" % "ackCordCommands" % "master-SNAPSHOT"
libraryDependencies += "net.katsstuff" %% "ackcord-commands" % "0.1"
```

### Command handlers
Expand Down
6 changes: 3 additions & 3 deletions ackCord/src/main/scala/net/katsstuff/ackcord/APIMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ object APIMessage {

/**
* Sent to the client when an user is banned from a guild. If you need the
* [[GuildMember]] object of the user, you can find it in [[prevSnapshot]].
* [[net.katsstuff.ackcord.data.GuildMember]] object of the user, you can find it in [[prevSnapshot]].
* @param guild The guild the user was banned from.
* @param user The banned user.
*/
Expand Down Expand Up @@ -192,7 +192,7 @@ object APIMessage {

/**
* Sent to the client when a user leaves the guild (or is kicked or banned).
* If you need the [[GuildMember]], you can find it in [[prevSnapshot]].
* If you need the [[net.katsstuff.ackcord.data.GuildMember]], you can find it in [[prevSnapshot]].
* @param user The user that left
* @param guild The guild the user left
*/
Expand All @@ -201,7 +201,7 @@ object APIMessage {

/**
* Sent to the client when a guild member is updated. The fields seen here
* are all the fields that can change. Looking at the users [[GuildMember]]
* are all the fields that can change. Looking at the users [[net.katsstuff.ackcord.data.GuildMember]]
* for changes is pointless.
* @param guild The guild of the guild member
* @param roles Thew new roles for the guild member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ sealed trait CacheHandlerEvent[Data] {
def handler: CacheHandler[Data]

/**
* Updates a [[CacheSnapshotBuilder]] with the data in this object.
* Updates a [[net.katsstuff.ackcord.handlers.CacheSnapshotBuilder]] with the data in this object.
*/
def handle(builder: CacheSnapshotBuilder)(implicit log: LoggingAdapter): Unit =
handler.handle(builder, data)
Expand All @@ -126,7 +126,7 @@ sealed trait CacheHandlerEvent[Data] {
* An event that should publish an [[APIMessage]]
* @param data The data
* @param sendEvent A function to gather the needed variables to send the
* event. The [[CacheSnapshot]]s passed is the current, and
* event. The [[net.katsstuff.ackcord.data.CacheSnapshot]]s passed is the current, and
* previous snapshot, in that order.
* @param handler The handler to process the data of this event with
* @tparam Data The data it contains
Expand Down
56 changes: 49 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,49 @@ lazy val akkaVersion = "2.5.6"
lazy val akkaHttpVersion = "10.0.10"
val circeVersion = "0.8.0"

lazy val commonSettings = Seq(scalaVersion := "2.12.2")
lazy val commonSettings = Seq(scalaVersion := "2.12.4", organization := "net.katsstuff")

lazy val publishSettings = Seq(
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ =>
false
},
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(
ScmInfo(
url("https://github.com/Katrix-/AckCord"),
"scm:git:github.com/Katrix-/AckCord",
Some("scm:git:github.com/Katrix-/AckCord")
)
),
homepage := Some(url("https://github.com/Katrix-/AckCord")),
pomExtra := {
<developers>
<developer>
<id>Katrix</id>
<name>Nikolai Frid</name>
<url>https://github.com/Katrix-</url>
</developer>
</developers>
}
)

lazy val ackCord = project
.settings(
commonSettings,
name := "AckCord",
publishSettings,
name := "ackcord",
version := "0.1",
resolvers += JCenterRepository,
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test",
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion
),
Expand All @@ -24,20 +56,30 @@ lazy val ackCord = project
"io.circe" %% "circe-shapes",
"io.circe" %% "circe-parser"
).map(_ % circeVersion),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % Test
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % Test,
description := "AckCord is a Scala library using Akka for the Discord API giving as much freedom as possible to the user"
)

lazy val example = project
.settings(
commonSettings,
name := "AckCord-example",
name := "ackcord-example",
version := "1.0",
libraryDependencies += "com.sedmelluq" % "lavaplayer" % "1.2.42"
)
.dependsOn(ackCord, ackCordCommands)

lazy val ackCordCommands = project
.settings(commonSettings, name := "AckCord-commands", version := "0.1")
.settings(
commonSettings,
publishSettings,
name := "ackcord-commands",
version := "0.1",
description := "AckCord-commands is an extension to AckCord to allow one to easily define commands"
)
.dependsOn(ackCord)

lazy val ackCordRoot = project.in(file(".")).aggregate(ackCord, example, ackCordCommands)
lazy val ackCordRoot = project
.in(file("."))
.aggregate(ackCord, example, ackCordCommands)
.settings(publish := {}, publishLocal := {}, publishArtifact := false)
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,20 @@ object InfoCommandHandler {
}

class KillCommand(main: ActorRef, val client: ClientActor) extends ParsedCommandActor[NotUsed] with ActorLogging {
context.watch(main)

override def receive: Receive = {
case DiscordClient.ShutdownClient => //We make sure to ignore this to be able to run code after the shutdown is complete
case Terminated(`main`) =>
log.info("Everything shut down")
context.system.terminate()
context.system.terminate()
case x if super.receive.isDefinedAt(x) => super.receive(x)
}

override def handleCommand(msg: Message, args: NotUsed, remaining: List[String])(implicit c: CacheSnapshot): Unit = {
log.info("Received shutdown command")
main ! ShutdownClient
context.watch(main)
}
}
object KillCommand {
Expand Down

0 comments on commit 8ac68b1

Please sign in to comment.