예제 #1
0
        internal void OnChat(IntPtr sender)
        {
            if (Chat == null && Console == null) return;

            ChatMessage chat;
            ChatType type;
            lock (this)
            {
                type = (ChatType) Functions.vp_int(pointer, IntAttributes.ChatType);

                if (type == ChatType.Normal)
                {
                    if (Chat == null)
                        return;
                    else
                        chat = new ChatMessage(sender);
                }
                else
                {
                    if (Console == null)
                        return;
                    else
                        chat = new ConsoleMessage(sender);
                }
            }

            if (type == ChatType.Normal)
                Chat(this, chat);
            else
                Console(this, (ConsoleMessage) chat);
        }
예제 #2
0
        void onChat(Instance sender, ChatMessage chat)
        {
            var user = GetUser(chat.Session);
            if ( user == null )
                return;

            if (Chat != null)
                Chat(sender, user, chat.Message);
        }
예제 #3
0
        void onChat(Instance bot, ChatMessage chat)
        {
            lock ( mutex )
            {
                string[] match;
                string[] wrongMatch;

                if ( !TRegex.TryMatch(chat.Message, entryInPlay.Answer, out match) )
                    return;

                if ( entryInPlay.Wrong != null && TRegex.TryMatch(chat.Message, entryInPlay.Wrong, out wrongMatch) )
                {
                    Log.Debug(tag, "Given answer '{0}' by {1} matched, but turned out to be wrong; rejecting", wrongMatch[0], chat.Name);
                    return;
                }

                gameEnd();

                var welldone = welldones.Skip(VPServices.Rand.Next(welldones.Length)).Take(1).Single();

                if ( match[0].IEquals(entryInPlay.CanonicalAnswer) )
                    app.Bot.ConsoleBroadcast(ChatEffect.Bold, VPServices.ColorInfo, "Triviamaster",
                        msgAccepted, entryInPlay.CanonicalAnswer, welldone, chat.Name);
                else
                    app.Bot.ConsoleBroadcast(ChatEffect.Bold, VPServices.ColorInfo, "Triviamaster",
                        msgAccepted, entryInPlay.CanonicalAnswer, match[0], welldone, chat.Name);

                Log.Debug(tag, "Correct answer '{0}' by {1}", match[0], chat.Name);
                awardPoint(chat.Name);
            }
        }
예제 #4
0
파일: IRC.cs 프로젝트: edwinr/VPServices
        void onWorldChat(Instance sender, ChatMessage chat)
        {
            if ( irc == null || !irc.IsConnected )
                return;

            var msg = string.Format("PRIVMSG {2} :{0}: {1}", chat.Name, chat.Message, channel);
            irc.SendRawMessage(msg);
        }