This repository has been archived by the owner on May 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
1 parent
c76d46d
commit dd46603
Showing
5 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
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,39 @@ | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using SCPDiscord.Interface; | ||
using Smod2.EventHandlers; | ||
using Smod2.Events; | ||
|
||
namespace SCPDiscord | ||
{ | ||
public class SynchronousExecutor : IEventHandlerFixedUpdate | ||
{ | ||
private readonly SCPDiscord plugin; | ||
private readonly ConcurrentQueue<ConsoleCommand> queuedCommands = new ConcurrentQueue<ConsoleCommand>(); | ||
|
||
public SynchronousExecutor(SCPDiscord pl) | ||
{ | ||
plugin = pl; | ||
} | ||
|
||
public void ScheduleConsoleCommand(ConsoleCommand command) | ||
{ | ||
queuedCommands.Enqueue(command); | ||
} | ||
|
||
public void OnFixedUpdate(FixedUpdateEvent ev) | ||
{ | ||
while(queuedCommands.TryDequeue(out ConsoleCommand command)) | ||
{ | ||
string[] words = command.Command.Split(' '); | ||
string response = plugin.ConsoleCommand(plugin.PluginManager.Server, words[0], words.Skip(1).ToArray()); | ||
Dictionary<string, string> variables = new Dictionary<string, string> | ||
{ | ||
{ "feedback", response } | ||
}; | ||
plugin.SendMessageByID(command.ChannelID, "botresponses.consolecommandfeedback", variables); | ||
} | ||
} | ||
} | ||
} |