Пример #1
0
        public bool Process(TypableMapCommandProcessor processor, Misuzilla.Net.Irc.PrivMsgMessage msg, Status status, string args)
        {
            Boolean isDestroy = (String.Compare(CommandName, "remove", true) == 0);

            return(processor.Session.RunCheck(() =>
            {
                if (isDestroy)
                {
                    processor.Session.TwitterService.DestroyFriendship(status.User.ScreenName);
                }
                else
                {
                    processor.Session.TwitterService.CreateFriendship(status.User.ScreenName);
                }

                processor.Session.SendServer(new NoticeMessage
                {
                    Receiver = msg.Receiver,
                    Content =
                        String.Format(
                            "ユーザ {0} を {1} しました。",
                            status.User.ScreenName, (isDestroy ? "remove" : "follow")
                            )
                });
            }));
        }
 public IrcTraceListener(Session session)
 {
     _session = session;
     #if FALSE
     if (_session.TcpClient.Connected)
     {
         PrivMsgMessage msg = new PrivMsgMessage("$ServerTraceLog", String.Format("(0x{0}) {1}", Thread.CurrentThread.ManagedThreadId.ToString("x"), "IrcTraceListener enabled."));
         msg.SenderNick = "trace";
         msg.SenderHost = "trace@" + Server.ServerName;
         msg.Receiver = _session.Nick;
         _session.Send(msg);
     }
     #endif
 }
Пример #3
0
        public override Boolean Execute(FilterArgs args)
        {
            if (String.IsNullOrEmpty(_channelName))
                return false;

            if (!String.IsNullOrEmpty(_matchPattern))
            {
                Boolean rerouteRequired =
                    Regex.IsMatch(args.Content, _matchPattern, RegexOptions.IgnoreCase) &&
                    ((String.IsNullOrEmpty(_userMatchPattern)) ? true : Regex.IsMatch(args.User.ScreenName, _userMatchPattern));

                if (!rerouteRequired)
                    return false;

                IRCMessage msg;
                switch (args.IRCMessageType.ToUpperInvariant())
                {
                    case "NOTICE":
                        msg = new NoticeMessage(_channelName, args.Content);
                        break;
                    case "PRIVMSG":
                    default:
                        msg = new PrivMsgMessage(_channelName, args.Content);
                        break;
                }
                msg.SenderNick = args.User.ScreenName;
                msg.SenderHost = "twitter@" + Server.ServerName;
                args.Session.Send(msg);

                if (!_duplicate)
                    args.Drop = true;

                return true;
            }
            return false;
        }
            public Boolean Process(TypableMapCommandProcessor processor, PrivMsgMessage msg, Status status, string args)
            {
                var session = processor.Session;
                if (args.Trim() == String.Empty)
                {
                    // ここに公式RT機能を実装
                    Status retweetStatus = processor.Session.TwitterService.RetweetStatus(status.Id);
                    session.SendChannelMessage(msg.Receiver, session.CurrentNick, String.Format(
                        "ユーザ {0} のステータス \"{1}\"をRetweetしました。",
                        retweetStatus.RetweetedStatus.User.ScreenName,
                        retweetStatus.Text), true, false, false, true
                    );

                    return true;
                }
                else
                {
                    session.SendChannelMessage(msg.Receiver, Server.ServerNick, "Retweetにメッセージ添付は有効ではありません。", true, false, false, true);
                }
                return true;
            }
            public Boolean Process(TypableMapCommandProcessor processor, PrivMsgMessage msg, Status status, string args)
            {
                var session = processor.Session;
                if (args.Trim() == String.Empty)
                {
                    session.SendChannelMessage(msg.Receiver, Server.ServerNick, "返信に空メッセージの送信はできません。", true, false, false, true);
                    return true;
                }

                String replyMsg = String.Format("@{0} {1}", status.User.ScreenName, args);

                // 入力が発言されたチャンネルには必ずエコーバックする。
                // 先に出しておかないとundoがよくわからなくなる。
                session.SendChannelMessage(msg.Receiver, session.CurrentNick, replyMsg, true, false, false, false);
                session.UpdateStatusWithReceiverDeferred(msg.Receiver, replyMsg, status.Id, (updatedStatus) =>
                                                                                                {
                                                                                                });
                return true;
            }
 public bool Process(TypableMapCommandProcessor processor, PrivMsgMessage msg, Status status, string args)
 {
     processor.Session.SendServer(new NoticeMessage
     {
         Receiver = msg.Receiver,
         Content = String.Format(
             "http://twitter.com/{0}/statuses/{1}",
             status.User.ScreenName,
             status.Id)
     });
     return true;
 }
 public bool Process(TypableMapCommandProcessor processor, PrivMsgMessage msg, Status status, string args)
 {
     return _processCommandDelegate(processor, msg, status, args);
 }
 public Boolean Process(TypableMapCommandProcessor processor, PrivMsgMessage msg, Status status, String args)
 {
     Boolean isUnfav = (String.Compare(CommandName, "unfav", true) == 0);
     processor.Session.RunCheck(() =>
                                    {
                                        Status favStatus = (isUnfav
                                                                ? processor.Session.TwitterService.DestroyFavorite(
                                                                      status.Id)
                                                                : processor.Session.TwitterService.CreateFavorite(
                                                                      status.Id));
                                        processor.Session.SendChannelMessage(msg.Receiver, processor.Session.CurrentNick, String.Format(
                                                                                 "ユーザ {0} のステータス \"{1}\"をFavorites{2}しました。",
                                                                                 favStatus.User.ScreenName,
                                                                                 favStatus.Text,
                                                                                 (isUnfav ? "から削除" : "に追加")), true, false, false, true);
                                    });
     return true;
 }
        public Boolean Process(PrivMsgMessage message)
        {
            if (_commands.Count == 0)
                return false;

            Match m = _matchRE.Match(message.Content);
            if (m.Success)
            {
                try
                {
                    Status status;
                    if (TypableMap.TryGetValue(m.Groups["tid"].Value, out status))
                    {
                        _commands[m.Groups["cmd"].Value].Process(this, message, status, m.Groups["args"].Value);
                    }
                    else
                    {
                        Session.SendServer(new NoticeMessage
                        {
                            Receiver = message.Receiver,
                            Content = "エラー: 指定された TypableMap の ID は存在しません。"
                        });
                    }
                }
                catch (Exception ex)
                {
                    Session.SendServer(new NoticeMessage
                    {
                        Receiver = message.Receiver,
                        Content = "エラー: TypableMap の処理中にエラーが発生しました。"
                    });
                    foreach (var line in ex.ToString().Split('\n'))
                    {
                        Session.SendServer(new NoticeMessage
                        {
                            Receiver = message.Receiver,
                            Content = line
                        });
                    }
                }

                return true; // 握りつぶす
            }

            return false;
        }
Пример #10
0
 public StatusUpdateEventArgs(PrivMsgMessage receivedMessage, String text)
 {
     ReceivedMessage = receivedMessage;
     Text = text;
 }
Пример #11
0
        internal void OnFeedItemReceived(object sender, FeedReceiveEventArgs e)
        {
            var config = sender as FeedReaderUrlConfiguration;

            String replacedSender = ReplaceFormattedString(config.SenderNick, config, e.Document, e.Item);
            String replacedContent = ReplaceFormattedString(config.ContentFormat, config, e.Document, e.Item);
            replacedContent = ApplyTypableMap(replacedContent, FeedItemToStatus(e.Item));

            foreach (String line in replacedContent.Split('\n'))
            {
                PrivMsgMessage priv = new PrivMsgMessage();
                priv.Sender = replacedSender;
                priv.Receiver = config.ChannelName;
                priv.Content = line;
                CurrentSession.Send(priv);
            }
        }