Basic bot pausing
This commit is contained in:
parent
eba589746b
commit
5b962bac2e
45
Bot/Bot.fs
45
Bot/Bot.fs
@ -1,5 +1,7 @@
|
||||
module Degenz.Bot
|
||||
|
||||
open System.IO
|
||||
open System.IO.Pipes
|
||||
open System.Threading.Tasks
|
||||
open DSharpPlus
|
||||
open DSharpPlus.SlashCommands
|
||||
@ -88,28 +90,41 @@ GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
|
||||
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
||||
|
||||
stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||
|
||||
//inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||
|
||||
//let channel = hackerBattleBot.GetChannelAsync(1234uL) |> Async.AwaitTask |> Async.RunSynchronously
|
||||
//channel.invi
|
||||
|
||||
let rec loop areBotsRunning =
|
||||
async {
|
||||
if not (File.Exists "fsharp-bots") then
|
||||
use file = File.Create "fsharp-bots"
|
||||
file.Flush()
|
||||
|
||||
let! file = File.ReadAllTextAsync("fsharp-bots") |> Async.AwaitTask
|
||||
|
||||
//async {
|
||||
// let! user = hackerBattleBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
|
||||
// if user <> null then
|
||||
// GuildEnvironment.botUserHackerBattle <- Some user
|
||||
// return ()
|
||||
//} |> Async.RunSynchronously
|
||||
let! ran =
|
||||
async {
|
||||
if areBotsRunning && file.StartsWith "kill" then
|
||||
printfn "Disconnecting bots"
|
||||
do! hackerBattleBot.DisconnectAsync() |> Async.AwaitTask
|
||||
do! storeBot.DisconnectAsync() |> Async.AwaitTask
|
||||
return false
|
||||
elif not areBotsRunning && not (file.StartsWith "kill") then
|
||||
printfn "Reconnecting bots"
|
||||
do! hackerBattleBot.ConnectAsync() |> Async.AwaitTask
|
||||
do! storeBot.ConnectAsync() |> Async.AwaitTask
|
||||
return true
|
||||
else
|
||||
return areBotsRunning
|
||||
}
|
||||
|
||||
do! Async.Sleep 3000
|
||||
return! loop (ran)
|
||||
}
|
||||
|
||||
Async.Start (loop true)
|
||||
|
||||
//async {
|
||||
// let! user = storeBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
|
||||
// if user <> null then
|
||||
// GuildEnvironment.botUserHackerBattle <- Some user
|
||||
// return ()
|
||||
//} |> Async.RunSynchronously
|
||||
|
||||
Task.Delay(-1)
|
||||
|> Async.AwaitTask
|
||||
|
Loading…
x
Reference in New Issue
Block a user