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


C# WinterBot.Send方法代码示例

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


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

示例1: ClearChat

        private void ClearChat(WinterBot sender, TwitchUser user, string clearReason, int minTimeout=1)
        {
            bool shouldMessage = !string.IsNullOrEmpty(clearReason);
            var now = DateTime.Now;
            TimeoutCount timeout;
            if (!m_timeouts.TryGetValue(user, out timeout))
            {
                timeout = m_timeouts[user] = new TimeoutCount(now);
            }
            else
            {
                shouldMessage &= (DateTime.Now > timeout.LastTimeout) && (DateTime.Now - timeout.LastTimeout).TotalMinutes > 60;
                timeout.Count = GetEffectiveCount(timeout) + 1;
            }

            timeout.LastTimeout = now;
            if (!m_chatOptions.ShouldTimeout(user))
                timeout.Count = 1;

            if (minTimeout < 1)
                minTimeout = 1;

            int duration = 0;
            switch (timeout.Count)
            {
                case 1:
                case 2:
                    duration = 1;
                    break;

                case 3:
                    shouldMessage = !string.IsNullOrEmpty(clearReason);
                    duration = 5 * 60;
                    break;

                case 4:
                    shouldMessage = !string.IsNullOrEmpty(clearReason);
                    duration = 10 * 60;
                    break;

                case 5:
                    shouldMessage = !string.IsNullOrEmpty(clearReason);
                    duration = 8 * 60 * 60;
                    break;
            }

            if (duration < minTimeout)
                duration = minTimeout;

            if (shouldMessage)
            {
                if (duration == 1)
                    sender.Send(MessageType.Timeout, Importance.Med, "{0}: {1} (This is not a timeout.)", user.Name, clearReason);
                else if (duration < 60)
                    sender.Send(MessageType.Timeout, Importance.High, "{0}: {1}", user.Name, clearReason);
                else if (duration < 3600)
                    sender.Send(MessageType.Timeout, Importance.High, "{0}: {1} ({2} minute timeout.)", user.Name, clearReason, duration / 60);
                else
                    sender.Send(MessageType.Timeout, Importance.High, "{0}: {1} ({2} hour timeout.)", user.Name, clearReason, duration / 3600);
            }

            sender.Timeout(user, duration);
            timeout.LastTimeout = now.AddSeconds(duration);
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:64,代码来源:TimeoutController.cs

示例2: EnforceBannedWord

        private string EnforceBannedWord(WinterBot bot, TwitchUser user, string word)
        {
            int timeout = m_banWordOptions.TimeOut;
            string msg = m_banWordOptions.Message;

            if (!string.IsNullOrWhiteSpace(msg))
                msg = msg.Replace("$word", word);

            if (timeout <= 0)
                return msg;

            if (!m_chatOptions.ShouldTimeout(user))
                timeout = 1;

            ClearChat(bot, user, null, timeout);

            if (!string.IsNullOrWhiteSpace(msg))
            {
                if (timeout == 1)
                    bot.Send(MessageType.Timeout, Importance.Med, "{0}: {1} (This is not a timeout.)", user.Name, msg);
                else
                    bot.Send(MessageType.Timeout, Importance.Med, "{0}: {1} ({2} second timeout.)", user.Name, msg, timeout);
            }

            return null;
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:26,代码来源:TimeoutController.cs

示例3: ClearChat

        private void ClearChat(WinterBot sender, TwitchUser user, string clearReason)
        {
            bool shouldMessage = !string.IsNullOrEmpty(clearReason);
            var now = DateTime.Now;
            TimeoutCount timeout;
            if (!m_timeouts.TryGetValue(user, out timeout))
            {
                timeout = m_timeouts[user] = new TimeoutCount(now);
            }
            else
            {
                shouldMessage &= (DateTime.Now > timeout.LastTimeout) && (DateTime.Now - timeout.LastTimeout).TotalMinutes > 60;

                int curr = timeout.Count;
                int diff = (int)(now - timeout.LastTimeout).TotalMinutes / 15;

                if (diff > 0)
                    curr -= diff;

                if (curr < 0)
                    curr = 0;

                timeout.Count = curr + 1;
            }

            timeout.LastTimeout = now;
            if (!m_chatOptions.ShouldTimeout(user))
                timeout.Count = 1;

            int duration = 0;
            switch (timeout.Count)
            {
                case 1:
                case 2:
                    if (shouldMessage)
                        sender.Send(MessageType.Timeout, "{0}: {1} (This is not a timeout.)", user.Name, clearReason);

                    sender.ClearChat(user);
                    break;

                case 3:
                    duration = 5;
                    sender.Send(MessageType.Timeout, "{0}: {1} ({2} minute timeout.)", user.Name, clearReason, duration);
                    sender.Timeout(user, duration * 60);
                    timeout.LastTimeout = now.AddMinutes(duration);
                    break;

                case 4:
                    duration = 10;
                    sender.Send(MessageType.Timeout, "{0}: {1} ({2} minute timeout.)", user.Name, clearReason, duration);
                    sender.Timeout(user, duration * 60);
                    timeout.LastTimeout = now.AddMinutes(duration);
                    break;

                default:
                    Debug.Assert(timeout.Count > 0);
                    sender.Send(MessageType.Timeout, "{0}: {1} (8 hour timeout.)", user.Name, clearReason);
                    sender.Timeout(user, 8 * 60 * 60);
                    timeout.LastTimeout = now.AddHours(8);
                    break;
            }
        }
开发者ID:BigAbboTT,项目名称:WinterBot,代码行数:62,代码来源:TimeoutController.cs


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