ニコニコ生放送用コメントビューア「やります!アンコちゃん」 公式wikiです。

プラグイン製作者向け For developers page.

追々作っていきます
アンケート
アンコちゃん側でアンケートの体裁を変更して表示させていますが、プラグイン側で簡単にアンケート結果を取り出すことができます。
/vote showresultをトリガとして、下記の値がセットされます。
変数説明
chat.cast.enqStrアンケートの選択肢、すでにお題がでたあとに放送に接続した場合はnullが入ります
chat.cast.enqResultアンケートの結果
chat.cast.enqTitleアンケートのタイトル
以下は、簡易アンケートプラグインの表示モードで、グラフに表示させるときのコードです
        If chat.Message.StartsWith("/vote showresult") Then
            _questionCount = 0
            If chat.cast.enqStr IsNot Nothing Then
                _questionCount = chat.cast.enqStr.Length
            Else
                _questionCount = chat.cast.enqResult.Length
            End If

            enqueteItemList.Clear()
            LibAnko.Utility.DoInvoke(
                Sub()
                    enqTitle.Text = chat.cast.enqTitle
                    For ii As Integer = 0 To _questionCount - 1
                        enqueteItemList.Add(New enqueteItem(IIf(chat.cast.enqStr Is Nothing, New String("**"), chat.cast.enqStr(ii)), chat.cast.enqResult(ii)))
                    Next
                    EnqueteItemBindingSource.ResetBindings(False)
                    DispCircleGraph()

                End Sub, Me)
コメント
  • コテハン
こんな風にして参照できます。
        void _host_ReceiveChat(object sender, ankoPlugin2.ReceiveChatEventArgs e)
        {
            if (!this.IsAlive)
                return;
            //情報があるかちゃんと確認
            if (e.Chat.userinfo != null)
            {
                //こてはん
                Console.WriteLine(e.Chat.userinfo.CharaName);
                //プロフィールの名前
                Console.WriteLine(e.Chat.userinfo.DisplayName);
            }
        }
  • サムネ
サムネのダウンロードは本体に任せて、サムネのフォルダーにあるファイルを取り出します。
あ、でも時間の掛かりそうな処理はスレッド化を忘れずに!
if (e.Chat.userinfo != null)
{
    if (!string.IsNullOrEmpty(e.Chat.userinfo.IconUrl) && !e.Chat.userinfo.IconUrl.Contains("blank"))
    {
        Image Icon = null;
        try
        {
            int height = 100;
            Icon = LibAnko.Utility.createThumbnail(LibAnko.Utility.checkCache(e.Chat.userinfo.userid,
                                               e.Chat.userinfo.IconUrl,
                                               _host.IconFolder,
                                              false),
                                              height, height);
            if (Icon != null)
            {
                e.Value = Icon;
            }
        }
        catch
        {
        }
    }
}
  • コメント数
  • 指定したコメントにカーソルをジャンプ
  • 右クリックでコメント選択してなんか処理
  • 同じ放送IDの放送一覧取得
放送情報
  • 経過時間(時間補正の仕方)
             //選択中の放送情報
             LibAnko.broadcast cast = _host.CurrentCast;
            //経過時間
            int dsptime = (LibAnko.Utility.DateTimeToUnixTime(DateTime.Now) - cast.start_time + cast.timefix) * 100;
            //残り時間 cast.end_timeは延長時の更新機能をONにしていないと更新されないので注意
            int nokori = (cast.end_time - LibAnko.Utility.DateTimeToUnixTime(DateTime.Now) + cast.timefix) * 100;
            //経過時間
            if (dsptime > 0)
                label1.Text = LibAnko.Utility.VposToTimeString(dsptime);
            //残り時間
           if (dsptime > 0)
              label2.Text = LibAnko.Utility.VposToTimeString(nokori);

  • コミュ限定かどうか
  • 予約枠かどうか(2.0.26)
  • 主かどうか
棒読みコントロール
  • プラグインからなんかしゃべらせたい
  • オリジナルアラートの作り方
http://live.nicovideo.jp/api/getalertinfoを使って必要情報を収集(認証付きの方法だと、一手間増えます)

libAnkoにXMLSocketクラスがありますので、それをつかうことで簡単にアラートを作成できます。

        private LibAnko.ClsNicoXMLClient Alert;
        private string _Alert_user;
        private string _Alert_userHash;
        private string _Alert_server;
        private int _Alert_port;
        private int _Alert_thread;

        //アラートAPIを呼び出して必要な情報を取得
        bool getAlertInfo()
        {
            //テキストとして取得
            string res = _host.GetHTTPResponse("http://live.nicovideo.jp/api/getalertinfo");
            if(res=="ServiceUnavailable")
                return false;

            if (!string.IsNullOrEmpty(res))
            {
                try
                {
                    System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
          //xmlをXmlDocumentに読み込んで扱いやすくする
                    xmldoc.LoadXml(res);
                    string status = LibAnko.Utility.SelectString(xmldoc, "getalertstatus/@status");
                    if (status != "ok") return false;
                    this._Alert_user = LibAnko.Utility.SelectString(xmldoc, "getalertstatus/user_id");
                    this._Alert_userHash = LibAnko.Utility.SelectString(xmldoc, "getalertstatus/user_hash");
                    this._Alert_server = LibAnko.Utility.SelectString(xmldoc, "getalertstatus/ms/addr");
                    this._Alert_port = LibAnko.Utility.SelectInt(xmldoc, "getalertstatus/ms/port", 0);
                    this._Alert_thread = LibAnko.Utility.SelectInt(xmldoc, "getalertstatus/ms/thread", 0);
                    return true;
                }
                catch { }
            }
            return false;
        }

        void StartAlert()
        {
            if(getAlertInfo()) 
            {
                Alert = new LibAnko.ClsNicoXMLClient();
                Alert.ReceivedMessage += new LibAnko.ReceivedMessageEventHandler(Alert_ReceivedMessage);
                Alert.DisConnect += new LibAnko.DisConnectEventHandler(Alert_DisConnect);
                Alert.Connected += new EventHandler(Alert_Connected);

                //Alert.Connect(サーバーのホスト名, ポート番号, スレッドID, 放送ID(コメビュとして使う時), ユーザID, プレミアム区分, 開始コメント番号);
                Alert.Connect(this._Alert_server, this._Alert_port, this._Alert_thread, "", 0, 0, -1);
            }
        }

アラートがくるとAlert_ReceivedMessageが呼び出されるので、処理していけば出来上がり。
メッセージの中に 放送ID,コミュID,ユーザID って感じでカンマ区切りで入ってきます。
ツイート
  • 任意の文言をツイートさせたい(2.0系では未実装)
その他
  • 独自にごにょごにょしたいのでセッション情報だけ欲しい

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

※現在 メンバー のみがコメント投稿可能な設定になっています。

広告

Menu


外部ツール

はじめてのニコニコ生放送
その他の情報
【メニュー編集】

メンバーのみ編集できます

メンバー募集!
閉じる
XP向けのサポートは終了しています。
古いバージョンを続けてお使いになると、データの整合がとれなくなりバージョンアップできなくなる場合がありますので、なるべく最新をお使いください。