feat: pat command
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,3 +7,5 @@ DerivedData/
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
.env
|
||||
dep/
|
||||
deploy.sh
|
||||
|
||||
@@ -5,7 +5,35 @@ struct Actions {
|
||||
mention.member?.nick ?? mention.global_name ?? mention.username
|
||||
}
|
||||
|
||||
static let hugRes = (try? String(contentsOfFile: "choices/hug.txt", encoding: .utf8))?
|
||||
static func performAction(ctx: Gateway.MessageCreate, client: DiscordClient, resOpts: [String]) async throws {
|
||||
let author = "**\(ctx.member?.nick ?? ctx.author?.global_name ?? ctx.author?.username ?? "Zundamon")**"
|
||||
let dests = ctx.mentions.map(getUserFromMention).map({ "**\($0)**" })
|
||||
let orig: String
|
||||
let dest: String
|
||||
if let firstDest = dests.first {
|
||||
orig = "\(author)"
|
||||
dest = "\(firstDest)"
|
||||
} else {
|
||||
orig = "**Zundamon**"
|
||||
dest = "\(author)"
|
||||
}
|
||||
|
||||
guard let res = resOpts.randomElement()?
|
||||
.replacingOccurrences(of: "{orig}", with: orig)
|
||||
.replacingOccurrences(of: "{dest}", with: dest)
|
||||
else { print("retOptions empty"); return }
|
||||
|
||||
let retMsg = res
|
||||
|
||||
try await client.createMessage(
|
||||
channelId: ctx.channel_id,
|
||||
payload: .init(
|
||||
embeds: [.init(description: retMsg)],
|
||||
)
|
||||
).guardSuccess()
|
||||
}
|
||||
|
||||
static let hugRes = (try? String(contentsOfFile: "resources/choices/hug.txt", encoding: .utf8))?
|
||||
.split(separator: "\n")
|
||||
.map({ $0.trimmingCharacters(in: .whitespacesAndNewlines) })
|
||||
|
||||
@@ -44,7 +72,7 @@ struct Actions {
|
||||
orig = "\(author)"
|
||||
dest = "\(firstDest)"
|
||||
} else {
|
||||
orig = "Zundamon"
|
||||
orig = "**Zundamon**"
|
||||
dest = "\(author)"
|
||||
}
|
||||
|
||||
@@ -63,4 +91,17 @@ struct Actions {
|
||||
)
|
||||
).guardSuccess()
|
||||
}
|
||||
|
||||
static let patRes = (try? String(contentsOfFile: "resources/choices/pat.txt", encoding: .utf8))?
|
||||
.split(separator: "\n")
|
||||
.map({ $0.trimmingCharacters(in: .whitespacesAndNewlines) })
|
||||
|
||||
static func pat(
|
||||
_ args: ArraySlice<String.SubSequence>,
|
||||
client: DiscordClient,
|
||||
ctx: Gateway.MessageCreate
|
||||
) async throws {
|
||||
guard let patRes = patRes else { print("pat.txt not loaded"); return }
|
||||
try await performAction(ctx: ctx, client: client, resOpts: patRes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ struct MessageHandler {
|
||||
let client: any DiscordClient
|
||||
|
||||
static let prefix = ":"
|
||||
static let zundaGifData = try? Data(contentsOf: URL(filePath: "media/zundamone.gif"))
|
||||
static let zundaGifData = try? Data(contentsOf: URL(filePath: "resources/media/zundamone.gif"))
|
||||
|
||||
func handle() async throws {
|
||||
guard !(ctx.author?.bot ?? false) else { return }
|
||||
@@ -20,6 +20,8 @@ struct MessageHandler {
|
||||
case "wow": try await handleWow(args)
|
||||
case "domath": try await Wolfram.handleMath(args, client: client, ctx: ctx)
|
||||
case "hug": try await Actions.hug(args, client: client, ctx: ctx)
|
||||
case "pat": try await Actions.pat(args, client: client, ctx: ctx)
|
||||
case "pet": try await Actions.pat(args, client: client, ctx: ctx)
|
||||
default: break
|
||||
}
|
||||
} else if ctx.mentions.contains(where: { $0.id == Zundamon.ownID }) {
|
||||
|
||||
10
resources/choices/pat.txt
Normal file
10
resources/choices/pat.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
{orig} moves their hand over to {dest}'s head and gave it a pleasure feeling.
|
||||
{orig} gently strokes {dest}'s head.
|
||||
{orig} softly strokes {dest}'s head as a sign of affection.
|
||||
{dest} timidly placed {orig}'s hand on their head.
|
||||
{dest} timidly placed {orig}'s hand on their head while blushing intensely.
|
||||
{orig} runs their finger through {dest}'s hair, lightly scratches {dest}'s head and caressing their hair strands.
|
||||
{orig} lightly scratches {dest}'s cheeks just behind the whiskers.
|
||||
{dest} lets out a quiet purr as {orig}'s fingers gently scratches {dest}'s head.
|
||||
{dest} smiled, slightly blushing, as {orig} playfully taps {dest}'s head.
|
||||
{orig} reaches over and lightly taps {dest}'s head.
|
||||
|
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
11
zundamon.service
Normal file
11
zundamon.service
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Zundamon Discord Bot
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=zundamon
|
||||
ExecStart=/usr/local/share/zundabot/zundamon
|
||||
WorkingDirectory=/usr/local/share/zundabot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user