当前位置: 首页>>代码示例>>C#>>正文


C# WinterBot.SendResponse方法代码示例

本文整理汇总了C#中Winter.WinterBot.SendResponse方法的典型用法代码示例。如果您正苦于以下问题:C# WinterBot.SendResponse方法的具体用法?C# WinterBot.SendResponse怎么用?C# WinterBot.SendResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Winter.WinterBot的用法示例。


在下文中一共展示了WinterBot.SendResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddCommand

        public void AddCommand(WinterBot sender, TwitchUser user, string c, string v)
        {
            Args args = v.ParseArguments(m_bot);

            AccessLevel level = args.GetAccessFlag("ul", AccessLevel.Mod);
            string cmdName = args.GetOneWord();
            string cmdText = args.GetString();

            if (string.IsNullOrWhiteSpace(cmdName) || string.IsNullOrWhiteSpace(cmdText) || args.Error != null)
            {
                sender.SendResponse(Importance.Med, m_addCommandUsage);
                return;
            }

            if (cmdName[0] != '!')
            {
                sender.SendResponse(Importance.Med, string.Format("User commands must start with a '!'. {0}", m_addCommandUsage));
                return;
            }
            else
            {
                cmdName = cmdName.Substring(1);
            }

            if (cmdText[0] == '.' || cmdText[0] == '/')
            {
                sender.SendResponse(Importance.Med, string.Format("Cannot create a command which starts with a '{0}'.", cmdText[0]));
                return;
            }

            cmdName = cmdName.ToLower();
            Command userCommand = new Command(level, cmdText);

            bool exists;
            lock (m_sync)
            {
                exists = m_commands.ContainsKey(cmdName);
                m_commands[cmdName] = userCommand;
                m_dirty = true;
            }

            if (exists)
            {
                sender.SendResponse(Importance.Med, string.Format("Updated command: !{0}.", cmdName));
                WinterBotSource.Log.AddCommand(user.Name, cmdName, cmdText);
            }
            else
            {
                sender.SendResponse(Importance.Med, string.Format("Successfully added command: !{0}.", cmdName));
                WinterBotSource.Log.UpdateCommand(user.Name, cmdName, cmdText);
            }
        }
开发者ID:KnightRobby,项目名称:WinterBot,代码行数:52,代码来源:BetterCommands.cs

示例2: Banliust

        public void Banliust(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (string.IsNullOrWhiteSpace(value))
                return;

            UrlMatch match = new UrlMatch(sender, value);
            m_urlBanlist.Add(match);
            sender.SendResponse(Importance.Med, "Added {0} to the url ban list.", value);
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:9,代码来源:TimeoutController.cs

示例3: AutoMessageMode

        public void AutoMessageMode(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            bool shouldEnable = false;
            if (value.Trim().ParseBool(ref shouldEnable))
            {
                m_msgOptions.Enabled = shouldEnable;
                if (shouldEnable)
                {
                    if (ShouldEnable)
                        Enable();
                    else
                        Disable();
                }

                sender.SendResponse(Importance.Med, "Auto message now {0}.", shouldEnable ? "enabled" : "disabled");
            }
            else
            {
                sender.SendResponse(Importance.Med, "Auto message is currently {0}.", m_msgOptions.Enabled ? "enabled" : "disabled");
            }
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:21,代码来源:Automessage.cs

示例4: SetRegular

        private void SetRegular(WinterBot sender, string cmd, string value, bool regular)
        {
            value = value.Trim().ToLower();
            if (!TwitchUsers.IsValidUserName(value))
            {
                sender.WriteDiagnostic(DiagnosticFacility.UserError, "{0}: Invalid username '{1}.", cmd, value);
                return;
            }

            TwitchUser target = sender.Users.GetUser(value);
            if (regular)
            {
                sender.AddRegular(target);
                sender.SendResponse("{0} added to regular list.", value);
            }
            else
            {
                sender.RemoveRegular(target);
                sender.SendResponse("{0} removed from regular list.", value);
            }
        }
开发者ID:BigAbboTT,项目名称:WinterBot,代码行数:21,代码来源:Regulars.cs

示例5: SetRegular

        private void SetRegular(WinterBot sender, string cmd, string value, bool regular)
        {
            value = value.Trim();
            if (!TwitchUsers.IsValidUserName(value))
            {
                sender.WriteDiagnostic(DiagnosticFacility.UserError, "{0}: Invalid username '{1}.", cmd, value);
                return;
            }

            TwitchUser target = sender.Users.GetUser(value);
            target.IsRegular = regular;
            sender.SendResponse(Importance.Med, "{0} {1} the regular list.", target.Name, regular ? "added to " : "removed from");
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:13,代码来源:Regulars.cs

示例6: JukeBoxCommand

        public void JukeBoxCommand(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (!m_enabled)
            {
                if (!sender.CanUseCommand(user, AccessLevel.Mod))
                {
                    if (m_lastMessage.Elapsed().TotalSeconds <= 30)
                        return;

                    m_lastMessage = DateTime.Now;
                    sender.SendResponse(Importance.Low, "The jukebox is CLOSED. No additional requests are being accepted.");
                    return;
                }

                value = value.Trim().ToLower();

                if (value == "on")
                {
                    m_enabled = true;
                    m_lastMessage = DateTime.Now;
                    sender.SendResponse(Importance.Med, "Jukebox activated.  Use '!JukeboxMode off' to deactivate.");
                }
                else if (value == "off")
                {
                    sender.SendResponse(Importance.Med, "Jukebox mode is off.");
                }
                else
                {
                    sender.SendResponse(Importance.Low, "Usage: '!jukebox on' and '!jukebox off'.  Mod only.");
                }
            }
            else
            {
                if (sender.CanUseCommand(user, AccessLevel.Mod))
                {
                    if (value == "on")
                    {
                        sender.SendResponse(Importance.Low, "Jukebox mode is already enabled.");
                    }
                    else if (value == "off")
                    {
                        sender.SendResponse(Importance.High, "The jukebox is shutting down for the night. Please hold your song requests for next time.");
                        m_enabled = false;
                    }
                    else
                    {
                        SendMessage(sender);
                    }
                }
                else
                {
                    if (m_lastMessage.Elapsed().TotalSeconds <= 10)
                        return;

                    m_lastMessage = DateTime.Now;
                    SendMessage(sender);
                }
            }
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:59,代码来源:JukeBox.cs

示例7: Deny

        public void Deny(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            value = value.Trim();

            if (!TwitchUsers.IsValidUserName(value))
            {
                sender.SendResponse(Importance.Med, "{0}: Usage: !deny [user]", user.Name);
                return;
            }

            var target = sender.Users.GetUser(value);
            if (target.IsModerator)
                return;

            if (m_permit.Contains(target))
                m_permit.Remove(target);

            m_denyList.Add(target);
            sender.SendResponse(Importance.High, "{0}: {1} is no longer allowed to post links.", user.Name, target.Name);
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:20,代码来源:TimeoutController.cs

示例8: ChangeMode

        private static bool ChangeMode(WinterBot sender, TwitchUser user, string value, string type, bool curr)
        {
            bool result = curr;

            value = value.Trim();
            if (string.IsNullOrWhiteSpace(value))
            {
                sender.SendResponse(Importance.Med, "{0} protect is currently {1}.", type, curr ? "enabled" : "disabled");
            }
            else if (value.ParseBool(ref result))
            {
                if (curr != result)
                {
                    string enableStr = result ? "enabled" : "disabled";
                    sender.SendResponse(Importance.Med, "{0} protect is now {1}.", type, enableStr);
                    sender.WriteDiagnostic(DiagnosticFacility.ModeChange, "{0} changed {1} mode to {2}.", user.Name, type, enableStr);
                }
            }
            return result;
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:20,代码来源:TimeoutController.cs

示例9: Spam

        public void Spam(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            value = value.ToLower().Trim();

            string timeE = "-time=";
            bool ban = false;
            int timeout = DefaultSpamTimeout;
            if (value.Contains(' '))
            {
                string[] split = value.Split(new char[] { ' ' }, 2);
                if (split[0] == "-ban")
                {
                    ban = true;
                    value = split[1];
                }
                else if (split[0].Length > timeE.Length && split[0].StartsWith(timeE))
                {
                    string strtime = split[0].Substring(timeE.Length);
                    if (!int.TryParse(strtime, out timeout))
                    {
                        sender.SendResponse(Importance.High, "Usage: !spam [-time=??] text to auto timeout");
                        return;
                    }

                    value = split[1];
                    if (timeout <= 0)
                        timeout = 1;
                }
            }

            if (string.IsNullOrWhiteSpace(value))
            {
                // We'll just treat this as turning it off.
                m_clearMsg = null;
                m_spamTimeout = DefaultSpamTimeout;
                return;
            }
            else
            {
                m_clearMsg = value;
                m_spamTimeout = ban ? (int?)null : timeout;

                if (ban)
                    sender.SendResponse(Importance.High, "Banning all messages containing '{0}'.", value);
                else if (timeout <= 1)
                    sender.SendResponse(Importance.High, "All messages containing '{0}' will be purged.", value);
                else
                    sender.SendResponse(Importance.High, "All messages containing '{0}' will receive a {1} second timeout.", value, timeout);
            }

            // Apply rule to recent messages
            HashSet<TwitchUser> timedOut = new HashSet<TwitchUser>();
            foreach (var msg in m_lastMsgs.Where(p => p != null && !string.IsNullOrWhiteSpace(p.Item2)))
            {
                if (timedOut.Contains(msg.Item1))
                    continue;

                if (CheckAndTimeoutSpam(sender, msg.Item1, msg.Item2))
                    timedOut.Add(msg.Item1);
            }
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:61,代码来源:TimeoutController.cs

示例10: ReportTotal

        private void ReportTotal(WinterBot sender)
        {
            if (!m_dirty)
                return;

            var votes = from item in m_result
                        group item by item.Value into g
                        let key = g.Key
                        let count = g.Sum(p => p.Key.IsSubscriber ? m_options.SubVoteCount : 1)
                        orderby key
                        select new
                        {
                            Option = key,
                            Votes = count
                        };

            var top = (from vote in votes orderby vote.Votes descending select vote).First();

            string msg = "@winter Current vote is for {0} with {1} votes. {2}";
            if (!m_active)
                msg = "@winter Voting closed.  Result: {0} with {1} votes. {2}";

            sender.SendResponse(Importance.Med, msg, top.Option, top.Votes, "(" + string.Join(", ", votes.Select(v => string.Format("Option {0}: {1} votes", v.Option, v.Votes))) + ".)");
            m_lastMessage = DateTime.Now;
            m_dirty = false;
        }
开发者ID:holyjaw,项目名称:WinterBot,代码行数:26,代码来源:AutoPoll.cs

示例11: OpenBetting

        public void OpenBetting(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (!Enabled)
                return;

            if (IsBettingOpen || WaitingResult)
            {
                sender.SendResponse(Importance.Low, "Betting is currently ongoing.  Use !result to award points, use !cancelbet to cancel the current bet.");
                return;
            }

            HashSet<string> betting = new HashSet<string>();
            Args args = value.ToLower().ParseArguments(sender);

            int time = args.GetIntFlag("time", 120, false);
            string val;
            while ((val = args.GetOneWord()) != null)
                betting.Add(val);

            if (betting.Count < 2)
            {
                sender.SendResponse(Importance.High, "Need at least two people to bet on!");
                return;
            }

            m_betting = betting;
            m_bets = new Dictionary<TwitchUser, Tuple<string, int>>();
            m_state = State.Open;
            m_time = time;
            m_bettingStarted = DateTime.Now;

            GetCallback();

            sender.SendResponse(Importance.High, "Betting is now OPEN.  Use '!bet [player] [amount]' to bet.  Minimum bet is 1, maximum bet is 500.  You start with 3000 points, you can bet even if you have no points.");
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:35,代码来源:Betting.cs

示例12: UnknownCommandReceived

        void UnknownCommandReceived(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            cmd = cmd.ToLower();
            Command command;

            lock (m_sync)
                if (!m_commands.TryGetValue(cmd, out command))
                    return;

            if (!sender.CanUseCommand(user, command.AccessLevel))
            {
                WinterBotSource.Log.DenyCommand(user.Name, cmd, "access");
                return;
            }

            if (CanSendCommand(user, cmd))
            {
                sender.SendResponse(Importance.Low, command.Text);
                m_sent.AddLast(new Tuple<string, DateTime>(cmd, DateTime.Now));
            }
        }
开发者ID:KnightRobby,项目名称:WinterBot,代码行数:21,代码来源:BetterCommands.cs

示例13: RemoveCommand

        public void RemoveCommand(WinterBot sender, TwitchUser user, string c, string a)
        {
            Args args = a.ParseArguments(m_bot);
            string cmd = args.GetOneWord();
            if (cmd == null)
            {
                sender.SendResponse(Importance.Med, m_removeCommandUsage);
                return;
            }

            if (cmd[0] == '!')
                cmd = cmd.Substring(1);

            lock (m_sync)
            {
                cmd = cmd.ToLower();
                if (m_commands.ContainsKey(cmd))
                {
                    m_commands.Remove(cmd);
                    m_remove.Add(cmd);
                    m_dirty = true;
                    sender.SendResponse(Importance.Low, string.Format("Removed command {0}.", cmd));
                    WinterBotSource.Log.RemoveCommand(user.Name, cmd);
                }
                else
                {
                    sender.SendResponse(Importance.Med, string.Format("Command {0} not found.", cmd));
                }
            }
        }
开发者ID:KnightRobby,项目名称:WinterBot,代码行数:30,代码来源:BetterCommands.cs

示例14: bot_Tick

        void bot_Tick(WinterBot sender, TimeSpan timeSinceLastUpdate)
        {
            if (m_enabled)
            {
                if (!sender.IsStreamLive)
                {
                    if (!m_streamDead)
                    {
                        m_streamDead = true;
                        m_lastOffline = DateTime.Now;
                    }
                    else if (m_lastOffline.Elapsed().TotalMinutes >= 10)
                    {
                        m_enabled = false;
                        m_streamDead = false;
                        sender.SendResponse(Importance.Med, "Disabling jukebox mode.");
                    }
                }
                else
                {
                    m_streamDead = false;
                }
            }

            if (m_enabled && m_lastMessage.Elapsed().TotalMinutes >= 7)
                SendMessage(sender);
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:27,代码来源:JukeBox.cs

示例15: SendMessage

 private void SendMessage(WinterBot bot)
 {
     m_lastMessage = DateTime.Now;
     bot.SendResponse(Importance.Low, m_message);
 }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:5,代码来源:JukeBox.cs


注:本文中的Winter.WinterBot.SendResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。