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
 | 
					module Degenz.Bot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					open System.IO
 | 
				
			||||||
 | 
					open System.IO.Pipes
 | 
				
			||||||
open System.Threading.Tasks
 | 
					open System.Threading.Tasks
 | 
				
			||||||
open DSharpPlus
 | 
					open DSharpPlus
 | 
				
			||||||
open DSharpPlus.SlashCommands
 | 
					open DSharpPlus.SlashCommands
 | 
				
			||||||
@ -88,28 +90,41 @@ GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
 | 
				
			|||||||
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
					storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
				
			||||||
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
 | 
					GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
					//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//inviterBot.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! ran =
 | 
				
			||||||
//    let! user = hackerBattleBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
 | 
					            async {
 | 
				
			||||||
//    if user <> null then
 | 
					                if areBotsRunning && file.StartsWith "kill" then
 | 
				
			||||||
//        GuildEnvironment.botUserHackerBattle <- Some user
 | 
					                    printfn "Disconnecting bots"
 | 
				
			||||||
//    return ()
 | 
					                    do! hackerBattleBot.DisconnectAsync() |> Async.AwaitTask
 | 
				
			||||||
//} |> Async.RunSynchronously
 | 
					                    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)
 | 
					Task.Delay(-1)
 | 
				
			||||||
|> Async.AwaitTask
 | 
					|> Async.AwaitTask
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user