Пример #1
0
        public override bool Handle(MessageContext context)
        {
            var match = _regex.Match(context.Message.Text);

            if (match.Success)
            {
                var name = match.Groups["thing"].Value;
                name = name.StartsWith("@")
                    ? name.ToLowerInvariant()
                    : name.ApplyCase(LetterCasing.Sentence);

                var op = match.Groups["op"].Value;
                if (op == "++")
                {
                    var karma    = _provider.Increase(context.Room, name);
                    var response = _incrementResponses[_random.Next(0, _incrementResponses.Length)];
                    context.Broadcast($"{name} {response} (Karma: {karma})");
                }
                else
                {
                    var karma    = _provider.Decrease(context.Room, name);
                    var response = _decrementResponses[_random.Next(0, _decrementResponses.Length)];
                    context.Broadcast($"{name} {response} (Karma: {karma})");
                }
                return(true);
            }
            return(false);
        }
Пример #2
0
 protected override bool HandleMention(MessageContext context, string message)
 {
     foreach (var phrase in _phrases)
     {
         if (message.Contains(phrase, StringComparison.OrdinalIgnoreCase))
         {
             context.Broadcast($"I'm sorry, {context.Message.FromUser.DisplayName}. I'm afraid I can't do that.");
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
 protected override void HandleCommand(MessageContext context, string[] args)
 {
     context.Broadcast("Pong!");
 }
Пример #4
0
        protected override void HandleCommand(MessageContext context, string[] args)
        {
            var elapsed = DateTime.Now - _started;

            context.Broadcast($"I've been sentient for {elapsed.Humanize(5, minUnit: TimeUnit.Second)}.");
        }
Пример #5
0
 protected override void HandleCommand(MessageContext context, string[] args)
 {
     context.Broadcast("1. Serve the public trust\n2. Protect the innocent\n3. Uphold the law");
 }