public void display(userEntry commandUser, string argumentString) { int quoteID; if (Int32.TryParse(argumentString, out quoteID)) { string getQuoteQuery = "SELECT * FROM quotes WHERE quoteID=" + quoteID + " LIMIT 1"; SQLiteCommand getQuoteCommand = new SQLiteCommand(getQuoteQuery, m_BotBrain.storageDB); SQLiteDataReader getQuoteReader = getQuoteCommand.ExecuteReader(); if (getQuoteReader.HasRows && getQuoteReader.Read()) { string submitter = Convert.ToString(getQuoteReader["submitter"]); string message = Convert.ToString(getQuoteReader["message"]); string game = Convert.ToString(getQuoteReader["game"]); m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("quoteDisplay"), quoteID, message, game)); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("quoteNotFound")); } } else { random(commandUser, argumentString); } }
public void choices(userEntry commandUser, string argumentString) { if (isActive) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("pollChoiceList"), getChoiceString()) + " " + m_BotBrain.localizer.getString("pollVoteHint")); } }
public void setOwner(userEntry commandUser, string argumentString) { string counterName; string argument; uint argCount = getSimpleArgs(argumentString, out counterName, out argument); if (argCount >= 1) { if (argCount == 2) { counterEntry curCount = checkCreateEntry(counterName); curCount.Owner = argument; m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterOwnerSetSuccess"), curCount.Name, argument)); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterOwnerSetFailEmpty")); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified")); } }
public void applyProfile(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(argumentString)) { streamProfileEntry useProfile; if (configData.entries.ContainsKey(argumentString)) { useProfile = configData.entries[argumentString]; TwitchLib.Api.Helix.Models.Channels.ModifyChannelInformation.ModifyChannelInformationRequest newChannelInfoRequest = new TwitchLib.Api.Helix.Models.Channels.ModifyChannelInformation.ModifyChannelInformationRequest() { Title = useProfile.title, GameId = useProfile.category }; List <string> newTags = useProfile.tags.GetRange(0, Math.Min(useProfile.tags.Count, TAGS_MAX)); int tagsCommonCount = TAGS_MAX - newTags.Count; for (int i = 0; i < tagsCommonCount; i++) { newTags.Add(configData.tagsCommon[i]); } m_BotBrain.updateChannelInfo(newChannelInfoRequest, newTags); if (!string.IsNullOrEmpty(useProfile.rewardGroup)) { applyRewardGroupInternal(useProfile.rewardGroup); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("modifyChannelInfoFailProfileNotFound")); } } }
public override void frame() { List <delaySendEntry> removedEntries = new List <delaySendEntry>(); for (int i = 0; i < m_Entries.Count; i++) { if (m_BotBrain.actionTimer.ElapsedMilliseconds >= m_Entries[i].sendTime) { string messageToSend = m_Entries[i].message; if (!String.IsNullOrEmpty(messageToSend)) { if (messageToSend.IndexOf('!') == 0) { userEntry botOwnerUser = m_BotBrain.checkCreateUser(m_BotBrain.ownerUsername); m_BotBrain.processUserCommand(botOwnerUser, messageToSend); } else { m_BotBrain.sendDefaultChannelMessage(messageToSend); } } removedEntries.Add(m_Entries[i]); } } for (int i = 0; i < removedEntries.Count; i++) { m_Entries.Remove(removedEntries[i]); } }
public void addEntry(userEntry commandUser, string argumentString) { if (m_Entries.Count < MAX_ENTRIES) { string[] argumentList = argumentString.Split(new[] { ' ' }, 2); if (argumentList.Length == 2) { long delayMS; if (long.TryParse(argumentList[0], out delayMS)) { delayMS *= 1000; if (delayMS <= MAX_DELAY_TIME && delayMS >= MIN_DELAY_TIME) { m_Entries.Add(new delaySendEntry(m_BotBrain.actionTimer.ElapsedMilliseconds + delayMS, commandUser, argumentList[1])); } else if (delayMS < MIN_DELAY_TIME) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("delayTimeShort"), MIN_DELAY_TIME)); } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("delayTimeLong"), MAX_DELAY_TIME)); } } } } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("delayQueueMax"), m_Entries.Count)); } }
private void checkCreateParticipant(userEntry aUser) { if (!m_Scores.ContainsKey(aUser)) { m_Scores[aUser] = 0; } }
private void setValue(userEntry commandUser, string argumentString, string commandName = "set") { string countName; int countValue; uint argCount = getModifyArgs(argumentString, out countName, out countValue); if (argCount >= 1) { if (argCount == 1) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterValueSetEmpty")); } counterEntry curCounter = checkCreateEntry(countName); if (curCounter.Owner == null || curCounter.Owner.ToLower() == commandUser.Nickname.ToLower()) { if (curCounter.set(countValue)) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterValueSet"), curCounter.Name, curCounter.Count, curCounter.Game)); } } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterValueSetFailOwner"), commandName, curCounter.Owner, curCounter.Name)); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified")); } }
public void remove(userEntry commandUser, string argumentString) { string countName; int countValue; uint argCount = getModifyArgs(argumentString, out countName, out countValue); if (argCount >= 1) { counterEntry curCounter = checkCreateEntry(countName); if (argCount == 1) { countValue = curCounter.Count - 1; } else { countValue = curCounter.Count - countValue; } setValue(commandUser, countName + " " + countValue, "remove"); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified")); } }
public void decide(userEntry commandUser, string argumentString) { try { Prediction lastPrediction = getLastPrediction(); if (lastPrediction != null && lastPrediction.Status == PredictionStatus.LOCKED) { int outcomeIndex; if (Int32.TryParse(argumentString, out outcomeIndex) && (outcomeIndex == 1 || outcomeIndex == 2) && lastPrediction.Outcomes.Length == 2) { Task decideTask = Task.Run(() => m_BotBrain.twitchAPI.Helix.Predictions.EndPredictionAsync(m_BotBrain.ownerID, lastPrediction.Id, PredictionEndStatus.RESOLVED, lastPrediction.Outcomes[outcomeIndex - 1].Id)); decideTask.Wait(); m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("predictionDecideSuccess"), lastPrediction.Outcomes[outcomeIndex - 1].Title)); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("predictionDecideFailOutcomeInvalid")); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("predictionDecideFailStatus")); } } catch (Exception e) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("predictionDecideFail")); } }
public void forceNext(userEntry commandUser, string argumentString) { if (m_Loaded) { sendNextMessage(); } }
public void draw(userEntry commandUser, string argumentString) { int userCount = userList.Count(); if (userCount > 0) { List <string> keyList = Enumerable.ToList(userList.Keys); string chosenKey = keyList[m_BotBrain.randomizer.Next(0, userCount - 1)]; userEntry chosenUser = userList[chosenKey]; userList.Remove(chosenKey); usersAddedRecently.Remove(chosenUser); if (usersAddedRecently.Count == 0) { userAddedRecently = false; } m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleUserSelected"), chosenUser.Nickname)); } else { if (m_IsActive) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleCountEmpty") + getJoinString()); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleCountEmpty") + " " + m_BotBrain.localizer.getString("raffleHintOpen")); } } }
public void applyRewardGroup(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(argumentString)) { applyRewardGroupInternal(argumentString); } }
public void describe(userEntry commandUser, string argumentString) { string counterName; string argument; uint argCount = getSimpleArgs(argumentString, out counterName, out argument); if (argCount >= 1) { if (argCount == 2) { counterEntry curCount = checkCreateEntry(counterName); if (curCount.describe(argument)) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionUpdateSuccess"), curCount.Name)); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterDescriptionUpdateFailEmpty")); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified")); } }
public override void onUserMessage(userEntry aUser, string aMessage) { if (m_IsActive) { triviaQuestion currentQuestion = getCurrentQuestion(); if (currentQuestion != null) { foreach (string curAnswer in currentQuestion.answers) { if (m_BotBrain.stripPunctuation(curAnswer.ToLower(), true) == m_BotBrain.stripPunctuation(aMessage.ToLower(), true)) { string addendumString = ""; if (!string.IsNullOrEmpty(currentQuestion.addendum)) { addendumString = " " + currentQuestion.addendum; } m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("triviaAnswerSuccess"), aUser.Nickname, aMessage) + addendumString); checkCreateParticipant(aUser); m_Scores[aUser]++; advanceToNextQuestion(true); return; } } } } }
public bool canUse(userEntry aUser, long aTimeNow) { if (aUser.isBroadcaster) { return(true); } if (isOnCooldown(aTimeNow, aUser)) { return(false); } if (m_AllowModerator && aUser.isModerator) { return(true); } else if (m_AllowNormal) { return(true); } else { return(false); } }
public override void onUserJoin(userEntry shoutUserEntry) { lurkShoutoutUser shoutEntry; for (int i = 0; i < configData.users.Count; i++) { shoutEntry = configData.users[i]; if (shoutEntry.name.ToLower() == shoutUserEntry.Nickname.ToLower()) { if (!shoutEntry.shoutedSinceLoad || m_BotBrain.actionTimer.ElapsedMilliseconds > (shoutEntry.lastShouted + shoutThrottle)) { shoutEntry.shoutedSinceLoad = true; shoutEntry.lastShouted = m_BotBrain.actionTimer.ElapsedMilliseconds; if (!string.IsNullOrEmpty(shoutEntry.shoutMessage)) { switch (shoutEntry.type) { default: case lurkShoutUserType.defaultType: m_BotBrain.sendDefaultChannelMessage(shoutEntry.shoutMessage); break; } } } return; } } }
public void about(userEntry commandUser, string argumentString) { string counterName; string argument; if (getSimpleArgs(argumentString, out counterName, out argument) >= 1) { counterEntry curCount = checkCreateEntry(counterName, false); if (curCount != null) { if (!string.IsNullOrEmpty(curCount.Description)) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionDisplay"), curCount.Name, curCount.Description)); } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionUpdateFailEmpty"), curCount.Name)); } } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterFailNotFound"), counterName)); } } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified")); } }
public void forceGame(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(argumentString)) { m_Game = argumentString; m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterGameSet"), argumentString)); } }
public void clearGame(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(m_Game)) { m_Game = null; m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterGameClear"), getGameString())); } }
public void getDeviceList(userEntry commandUser, string argumentString) { for (int i = 0; i < WaveOut.DeviceCount; i++) { WaveOutCapabilities curDevice = WaveOut.GetCapabilities(i); m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("soundDeviceListEntry"), i, curDevice.ProductName)); } }
public void question(userEntry commandUser, string argumentString) { triviaQuestion currentQuestion = getCurrentQuestion(); if (currentQuestion != null) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("triviaQuestionCurrent"), getCurrentQuestion().getFormattedTitle())); } }
public void close(userEntry commandUser, string argumentString) { m_IsActive = false; m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleClosed")); if (m_UsePointRedemption) { updateChannelPointRedemptionRewardEnabled(false); } }
public void setOffset(userEntry commandUser, string argumentString) { int offsetVal; if (Int32.TryParse(argumentString, out offsetVal)) { m_HoursPassedOffset = offsetVal; m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("hydrateReminderHoursPassedOffset"), m_HoursPassedOffset)); } }
public void describe(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(argumentString)) { m_Description = argumentString; if (m_IsActive) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleDescriptionSet")); } } }
public void setVolume(userEntry commandUser, string argumentString) { float newVolume; if (float.TryParse(argumentString, out newVolume)) { newVolume = Math.Min(newVolume, 1.0f); m_GlobalVolume = newVolume; m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("soundSetGlobalVolume"), newVolume)); } }
public void addUser(userEntry commandUser, string argumentString) { if (m_UsePointRedemption) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleAddUserFailNeedRedemption"), commandUser.Nickname, m_config.rewardInfo.title)); } else { addUserInternal(commandUser); } }
public override void onChannelPointRedemption(userEntry aMessageUser, string aRewardTitle, int aRewardCost, string aRewardUserInput, string aRewardID, string aRedemptionID) { if (m_LoadSuccessful) { bool needRefund = false; string failReason = ""; if (aRewardTitle == m_config.rewardInfo.title) { if (m_UsePointRedemption) { if (m_IsActive) { if (!userList.ContainsKey(aMessageUser.Nickname)) { if (updateRaffleRewardRedemptionStatus(aRewardID, aRedemptionID, TwitchLib.Api.Core.Enums.CustomRewardRedemptionStatus.FULFILLED)) { addUserInternal(aMessageUser); } else { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleRewardRedeemStatusFulfilledFail"), aMessageUser.Nickname)); } } else { failReason = m_BotBrain.localizer.getString("raffleRewardRedeemFailUserExists"); needRefund = true; } } else { failReason = m_BotBrain.localizer.getString("raffleRewardRedeemFailInactive"); needRefund = true; } } else { failReason = m_BotBrain.localizer.getString("raffleRewardRedeemFailNoRewardRequired"); needRefund = true; } if (needRefund) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleRewardRefund"), aMessageUser.Nickname, failReason)); if (!updateRaffleRewardRedemptionStatus(aRewardID, aRedemptionID, TwitchLib.Api.Core.Enums.CustomRewardRedemptionStatus.CANCELED)) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleRewardRedeemStatusCanceledFail"), aMessageUser.Nickname)); } } } } }
public void about(userEntry commandUser, string argumentString) { if (!string.IsNullOrEmpty(m_Description)) { m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("raffleDescriptionAnnounce"), m_Description)); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleDescriptionEmpty")); } }
public void reloadMessages(userEntry commandUser, string argumentString) { if (loadConfig()) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("hostMessageLoadSuccess")); } else { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("hostMessageLoadFail")); } }