void OnPrivMsg(TwitchIRCMessage message) { //if (activeChatWindow != null && !message.Message.StartsWith("!") && message.User != ToolkitSettings.Username) //{ // if ((_voteActive && !int.TryParse(message.Message[0].ToString(), out int result)) || !_voteActive) // { // activeChatWindow.AddMessage( // message.Message, // message.User, // (message.Parameters.ContainsKey("color")) ? message.Parameters["color"].Remove(0, 1) : Viewer.GetViewerColorCode(message.User) // ); // } //} message.Viewer = TwitchViewer.GetTwitchViewer(message.User); if (message.Viewer == null) { Helper.Log(message.User.CapitalizeFirst() + " tried to run a command but is not registed."); return; } if (Helper.ModActive) { CommandsHandler.CheckCommand(message); } if (VoteHandler.voteActive && int.TryParse(message.Message[0].ToString(), out int voteKey)) { VoteHandler.currentVote.RecordVote(Viewers.GetViewer(message.User).id, voteKey - 1); } }
public override void ParseCommand(ChatMessage msg) { if (msg.Message.StartsWith("!lookup") && CommandsHandler.AllowCommand(msg)) { string[] command = msg.Message.Split(' '); if (command.Length < 2) { return; } string searchObject = command[1].ToLower(); if (searchObject == null || searchObject == "") { return; } string searchQuery = null; if (command.Length > 2) { searchQuery = command[2].ToLower(); } if (searchQuery == null) { searchQuery = ""; } FindLookup(msg, searchObject, searchQuery); } Store_Logger.LogString("Finished lookup parse"); }
void OnPrivMsg(IRCMessage message) { Store_Logger.LogString(message.Message); Store_Logger.LogString($"connected: {Toolkit.client.client.Connected} - {DateTime.Now.ToShortTimeString()}"); //if (activeChatWindow != null && !message.Message.StartsWith("!") && message.User != ToolkitSettings.Username) //{ // if ((_voteActive && !int.TryParse(message.Message[0].ToString(), out int result)) || !_voteActive) // { // activeChatWindow.AddMessage( // message.Message, // message.User, // (message.Parameters.ContainsKey("color")) ? message.Parameters["color"].Remove(0, 1) : Viewer.GetViewerColorCode(message.User) // ); // } //} Store_Logger.LogString("Checking command"); if (Helper.ModActive) { CommandsHandler.CheckCommand(message); } Store_Logger.LogString("Checking if is vote"); if (VoteHandler.voteActive && int.TryParse(message.Message[0].ToString(), out int voteKey)) { VoteHandler.currentVote.RecordVote(Viewers.GetViewer(message.User).id, voteKey - 1); } }
public override void RunCommand(IRCMessage message) { if ((DateTime.Now - Cooldowns.modsCommandCooldown).TotalSeconds <= 15) { return; } Cooldowns.modsCommandCooldown = DateTime.Now; string modmsg = "Version: " + Toolkit.Mod.Version + ", Mods: "; string[] mods = LoadedModManager.RunningMods.Select((m) => m.Name).ToArray(); for (int i = 0; i < mods.Length; i++) { modmsg += mods[i] + ", "; if (i == (mods.Length - 1) || modmsg.Length > 256) { modmsg = modmsg.Substring(0, modmsg.Length - 2); Toolkit.client.SendMessage(modmsg, CommandsHandler.SendToChatroom(message)); modmsg = ""; } } return; }
protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { // Save context variable if (context == null) { context = turnContext; } // Register user var id = turnContext.Activity.Conversation.Id; if (!db.IsUserAdded(id)) { db.TryToAddUser(new TUser() { Id = id }); db.AddUserForVisit(id, turnContext.Activity.From.Name); } // Count visit db.AddVisit(id); var commandHandler = new CommandsHandler(cacheDictionary, commands); commandHandler.Execute(id, turnContext.Activity.Text); //// Execute previous command (if exists) //if (cacheDictionary.ContainsKey(id) && cacheDictionary.GetValue(id).ContainsKey("next")) //{ // foreach (var command in commands) // { // if (command.Contains(cacheDictionary.GetValue(id)["next"])) // { // var message = command.Execute(id, turnContext.Activity.Text); // if (message != null) // await turnContext.SendActivityAsync(MessageFactory.Text(message), cancellationToken); // return; // } // } //} //// Execute command by user message (if previous command is null) //foreach (var command in commands) //{ // if (command.Contains(turnContext.Activity.Text)) // { // var message = command.Execute(id, turnContext.Activity.Text); // if (message != null) // await turnContext.SendActivityAsync(MessageFactory.Text(message), cancellationToken); // return; // } //} // Write all commands (if previous command is null and user message is not command) foreach (var command in commands) { await turnContext.SendActivityAsync(MessageFactory.Text($"{command.Name} ({command.GetDescription()}) \n"), cancellationToken); } }
public async Task <CommandResult> GetErrorAsync(CommandsHandler handler) { if (Movies.Count() < 8) { return(await Task.FromResult(new CommandResult(ErrorCode.InvalidParameters, "Movies list should have 8 movies"))); } return(null); }
public override void RunCommand(TwitchIRCMessage message) { if (message.Message.Split(' ').Count() < 2) { return; } Purchase_Handler.ResolvePurchase(message.Viewer, message, CommandsHandler.SendToChatroom(message)); }
public override void RunCommand(IRCMessage message) { Viewer viewer = Viewers.GetViewer(message.User); if (message.Message.Split(' ').Count() < 2) { return; } Purchase_Handler.ResolvePurchase(viewer, message, CommandsHandler.SendToChatroom(message)); }
public override void RunCommand(TwitchIRCMessage message) { Helper.Log("running balance command"); Toolkit.client.SendMessage( $"@{message.Viewer.UsernameCap} " + Helper.ReplacePlaceholder("TwitchToolkitBalanceMessage".Translate(), amount: message.Viewer.Coins.ToString(), karma: message.Viewer.Karma.ToString()), CommandsHandler.SendToChatroom(message) ); }
private void HandleFilesHashesMessage(FilesHashesMessage message) { Application.Current.Dispatcher.Invoke(async() => { // Updater if (await this.ShowUpdatesAsync(message.FilesHashes)) { Environment.Exit(0); return; } // Loading try { var controller = await this.ShowProgressAsync(LanguageManager.Translate("483"), Randomize.GetRandomLoadingText()); await Task.Run(async() => { Protocol.Messages.MessagesBuilder.Initialize(); controller.SetProgress(0.14); await Task.Delay(200); TypesBuilder.Initialize(); controller.SetProgress(0.28); await Task.Delay(200); DataManager.Initialize(DTConstants.AssetsVersion, GlobalConfiguration.Instance.Lang); controller.SetProgress(0.42); await Task.Delay(200); MapsManager.Initialize(DTConstants.AssetsVersion); controller.SetProgress(0.56); await Task.Delay(200); FramesManager.Initialize(); controller.SetProgress(0.70); await Task.Delay(200); CommandsHandler.Initialize(); BreedsUtility.Initialize(); controller.SetProgress(1); await Task.Delay(200); LuaScriptManager.Initialize(); }); await controller.CloseAsync(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); }
public async Task <GameState> Handle(Guid tableId, TimeoutCommand command) { Task <GameState> loadStateTask = _reader.LoadTableState(tableId); await loadStateTask; GameState currentState = loadStateTask.Result; GameState newState = CommandsHandler.Handle(currentState, command); await _writer.WriteGameState(newState); return(newState); }
public override void ParseMessage(ITwitchMessage twitchMessage) { Log.Message("Starting toolkit message parsing"); if (Helper.ModActive) { CommandsHandler.CheckCommand(twitchMessage); } if (VoteHandler.voteActive && int.TryParse(twitchMessage.Message, out int voteId)) { VoteHandler.currentVote.RecordVote(Viewers.GetViewer(twitchMessage.Username).id, voteId - 1); } }
public override void ParseCommand(global::TwitchLib.Client.Models.ChatMessage message) { if (Helper.ModActive) { CommandsHandler.CheckCommand(message); } if (VoteHandler.voteActive && int.TryParse(message.Message, out int voteId)) { VoteHandler.currentVote.RecordVote(Viewers.GetViewer(message.Username).id, voteId - 1); } TwitchToolkit_MainTabWindow.LogChatMessage(message); }
static void Main(string[] args) { var commands = new string[] { }; if (args.Any()) { if (!File.Exists(args[0])) { Console.WriteLine($"Invalid file path in args. {Environment.NewLine}Provide absolute path to file e.g. C:\\InputCommands.txt"); return; } else { commands = File.ReadAllLines(args[0]); } } // Initialize family tree var family = new FamilyTreeHandler(); family.addFamilyHead("Queen-Margret", "Female"); family.AddSpouse("Queen-Margret", "King-Arthur", "Male"); // Build family tree var familyMmembersData = new FamilyDataBuilder(); var membersData = familyMmembersData.GenerateFamilyCommands(); foreach (var data in membersData) { CommandsHandler.ProcessCommand(family, data); } // var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"DataSource\InputFamilyData.txt"); foreach (var command in commands) { if (string.IsNullOrEmpty(command)) { continue; } var outcome = CommandsHandler.ProcessCommand(family, command.Trim()); Console.WriteLine(outcome); } Console.ReadLine(); }
public override void RunCommand(IRCMessage message) { Command buyCommand = DefDatabase <Command> .GetNamed("Buy"); string minutess = ToolkitSettings.CoinInterval > 1 ? "s" : ""; string storeon = buyCommand.enabled ? "TwitchToolkitOn".Translate() : "TwitchToolkitOff".Translate(); string earningcoins = ToolkitSettings.EarningCoins ? "TwitchToolkitOn".Translate() : "TwitchToolkitOff".Translate(); string stats_message = Helper.ReplacePlaceholder("TwitchToolkitModSettings".Translate(), amount: ToolkitSettings.CoinAmount.ToString(), first: ToolkitSettings.CoinInterval.ToString(), second: storeon, third: earningcoins, karma: ToolkitSettings.KarmaCap.ToString() ); Toolkit.client.SendMessage(stats_message, CommandsHandler.SendToChatroom(message)); }
static void Handle(WorldClient client, string message, ChatActivableChannelsEnum channel) { if (message.StartsWith(CommandsHandler.CommandsPrefix)) { CommandsHandler.Handle(message, client); return; } var handler = ChatHandlers.FirstOrDefault(x => x.Key == channel); if (handler.Value != null) { handler.Value(client, message); } else { client.Character.Reply("Ce chat n'est pas géré"); } }
public override void RunCommand(IRCMessage message) { List <Command> commands = DefDatabase <Command> .AllDefs.Where(s => !s.requiresAdmin && !s.requiresMod && s.enabled).ToList(); string output = "@" + message.User + " viewer commands: "; for (int i = 0; i < commands.Count; i++) { output += "!" + commands[i].command; if (i < commands.Count - 1) { output += ", "; } } Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(message)); }
public static void InitializeBot(Secrets secrets) { Secrets = secrets; HostChannelName = secrets.HostChannelName; TMICredentials = new ConnectionCredentials(secrets.HostChannelName, secrets.BotTMIOAuthKey); TwitchClient = new TwitchClient(); TwitchClient.Initialize(TMICredentials, secrets.HostChannelName); if (!TwitchClient.IsInitialized) { Console.WriteLine("Twitch Client did not initialize."); return; } TwitchClient.Connect(); if (!TwitchClient.IsConnected) { Console.WriteLine("Twitch Client was not able to connect."); return; } TwitchClient.JoinChannel(secrets.HostChannelName); BotAPI = new TwitchAPI(); BotAPI.Settings.ClientId = Secrets.BotClientID; BotAPI.Settings.Secret = secrets.BotClientSecret; HostAPI = new TwitchAPI(); HostAPI.Settings.ClientId = Secrets.HostClientID; HostAPI.Settings.Secret = secrets.HostClientSecret; CommandsHandler = new CommandsHandler(); VisitorTracker = new VisitorTracker(); CurrencyHandler = new CurrencyHandler(); TwitchClient.OnLog += OnLog; }
protected static void SendWrappedOutputText(string text, IRCMessage message) { if (string.IsNullOrEmpty(text)) { return; } string[] originalLines = text.Split(new string[] { " " }, StringSplitOptions.None); List <string> wrappedLines = new List <string>(); StringBuilder actualLine = new StringBuilder(); int actualLength = 0; foreach (var item in originalLines) { if (actualLength + item.Length + 1 > TWITCH_MSG_MAX_SIZE - 5) { actualLine.Append("(...)"); wrappedLines.Add(actualLine.ToString()); actualLine = new StringBuilder(); actualLength = 0; } actualLine.Append(item + " "); actualLength += item.Length + 1; } if (actualLine.Length > 0) { wrappedLines.Add(actualLine.ToString()); } if (wrappedLines.Count > 0) { foreach (string outputMessage in wrappedLines) { Toolkit.client.SendMessage(outputMessage, CommandsHandler.SendToChatroom(message)); } } }
public void SendTenResults(IRCMessage msg, string searchObject, string searchQuery, string[] results) { if (results.Count() < 1) { return; } string output = "Lookup for " + searchObject + " \"" + searchQuery + "\": "; for (int i = 0; i < results.Count(); i++) { output += results[i].CapitalizeFirst(); if (i != results.Count() - 1) { output += ", "; } } Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(msg)); }
protected static Pawn GetPawnIfAllowed(IRCMessage message) { Viewer viewer = Viewers.GetViewer(message.User); GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>(); if (!CommandsHandler.AllowCommand(message)) { // No commands allowed in this channel return(null); } Log.Message($"Parsing command {message.Message} from {message.User}"); if (!component.HasUserBeenNamed(viewer.username)) { Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", CommandsHandler.SendToChatroom(message)); return(null); } return(component.PawnAssignedToUser(viewer.username)); }
public BotClient() { _logger = Logging.GetLogger <BotClient>(); _botDataManager = new BotDataManager(); _usersManager = new UsersManager(_botDataManager); throttler = new MessageThrottling(_botDataManager); chatMessagePrefix = string.Format(":{0}!{0}@{0}.tmi.twitch.tv PRIVMSG #{1} :", _botDataManager.Login.BotName, _botDataManager.Login.Channel); _pointsManager = new PointsManager(_botDataManager, _usersManager, false); _experienceManager = new ExperienceManager(_botDataManager, _usersManager, false); _commandsHandler = new CommandsHandler(_usersManager, _botDataManager, _experienceManager, _pointsManager); _commandsHandler.OnCommandResponse += CommandsHandler_OnCommandResponse; this.readingTimer = new Timer(Reader_Timer_Tick, null, Timeout.Infinite, 200); this.uptimeTimer = new Timer(Uptime_Timer_Tick, null, Timeout.Infinite, 1000); this.uptime = new Stopwatch(); SetupEvents(); // Task.Run(() => TestAPI()).Wait(); }
public async Task <CommandResult> ExecuteAsync(CommandsHandler handler) { var obj = new Championship(); obj.AddMovies(Movies); obj.GenerateQuartersFinals(); obj.PlayQuarterFinals(); obj.GenerateSemiFinals(); obj.PlaySemiFinals(); obj.GenerateFinals(); obj.PlayFinals(); var rs = new List <Movie>(); rs.Add(obj.First); rs.Add(obj.Second); return(await Task.FromResult(new CommandResult(rs))); }
public EBotClient(string token, string prefix) { Console.Clear(); Console.Title = "EBot's Logs"; this._Token = token; this._Prefix = prefix; this._Log = new BotLog(); this._Event = new LogEvent(); this._Spy = new SpyLog(); this._Handler = new CommandsHandler(); this._Source = new CommandSource(this._Handler, this._Log); this._Discord = new DiscordSocketClient(); this._DiscordREST = new DiscordRestClient(); this._Log.Nice("Config", ConsoleColor.Yellow, "Token used => [ " + token + " ]"); this._Log.Notify("Initializing"); this._Handler.Client = this._Discord; this._Handler._RESTClient = this._DiscordREST; this._Handler.Log = this._Log; this._Handler.Prefix = this._Prefix; this._Handler.Source = this._Source; this._Handler.EmbedReply.Log = this._Log; this._Handler.Initialize(); this._Spy.Client = this._Discord; this._Spy.RESTClient = this._DiscordREST; this._Spy.Log = this._Log; this._Spy.WatchWords(new string[] { "yara", "earu" }); this._Event.Client = this._Discord; this._Event.RESTClient = this._DiscordREST; this._Event.Prefix = this._Prefix; this._Event.Log = this._Log; this._Event.InitEvents(); CLIENT = this; }
static void Main(string[] args) { String command; bool quitNow = false; Grid grid = new Grid(5, 5); Robot robot = new Robot(); CommandsHandler commandHandler = new CommandsHandler(robot, grid); ConsoleOutputHandler consoleOutputHandler = new ConsoleOutputHandler(); Console.WriteLine("Please insert a command(file filename.txt|place x,y,f|move|left|right|report) or /quit to exit!"); bool isEndOfFile = false; while (!quitNow) { if (commandHandler.IsFileInput && !isEndOfFile) { command = commandHandler.FileHandler.ReadLineFromFile(out isEndOfFile); } else { if (isEndOfFile) { consoleOutputHandler.PrintMessage("File parsing finished! You can find the output in output.txt file."); } command = Console.ReadLine(); } if (command == "/quit") { quitNow = true; continue; } commandHandler.HandleInput(command); } }
public override void ParseMessage(ITwitchMessage twitchMessage) { if (twitchMessage.Username == "hodlhodl" && twitchMessage.Message == "!hodleasteregg") { EasterEgg.Execute(); return; } if (ToolkitCoreSettings.forceWhispers && twitchMessage.WhisperMessage == null) { return; } if (Helper.ModActive) { CommandsHandler.CheckCommand(twitchMessage); } if (VoteHandler.voteActive && int.TryParse(twitchMessage.Message, out int voteId)) { VoteHandler.currentVote.RecordVote(Viewers.GetViewer(twitchMessage.Username).id, voteId - 1); } }
public void Setup(CommandsHandler handler, BotLog log) { this.Handler = handler; this.Log = log; }
public override void RunCommand(TwitchIRCMessage message) { try { string[] command = message.Message.Split(' '); if (command.Length < 3) { return; } string receiver = command[1].Replace("@", ""); if (message.User.ToLower() != ToolkitSettings.Channel.ToLower() && receiver.ToLower() == message.User.ToLower()) { Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitModCannotGiveCoins".Translate()); return; } int amount; bool isNumeric = int.TryParse(command[2], out amount); if (isNumeric) { Viewer giftee = ViewerModel.GetViewerByTypeAndUsername(receiver, message.Viewer.ViewerType); Helper.Log($"Giving viewer {giftee.Username} {amount} coins"); giftee.GiveCoins(amount); Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitGivingCoins".Translate(), viewer: giftee.Username, amount: amount.ToString(), newbalance: giftee.Coins.ToString()), CommandsHandler.SendToChatroom(message)); Store_Logger.LogGiveCoins(message.User, giftee.Username, amount); } } catch (InvalidCastException e) { Helper.Log("Invalid Give Viewer Coins Command " + e.Message); } }
public override void RunCommand(TwitchIRCMessage message) { try { string[] command = message.Message.Split(' '); if (command.Length < 2) { return; } bool isNumeric = int.TryParse(command[1], out int amount); if (isNumeric) { foreach (Viewer vwr in ViewerModel.All) { vwr.GiveCoins(amount); } Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitGiveAllCoins".Translate(), amount: amount.ToString()), CommandsHandler.SendToChatroom(message)); } } catch (InvalidCastException e) { Helper.Log("Give All Coins Syntax Error " + e.Message); } }
public override void RunCommand(TwitchIRCMessage message) { if (ToolkitSettings.EarningCoins) { ToolkitSettings.EarningCoins = false; Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOff".Translate(), CommandsHandler.SendToChatroom(message)); } else { ToolkitSettings.EarningCoins = true; Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOn".Translate(), CommandsHandler.SendToChatroom(message)); } }