プラグイン製作者向け For developers page.
追々作っていきます
あ、でも時間の掛かりそうな処理はスレッド化を忘れずに!
libAnkoにXMLSocketクラスがありますので、それをつかうことで簡単にアラートを作成できます。
メッセージの中に 放送ID,コミュID,ユーザID って感じでカンマ区切りで入ってきます。
追々作っていきます
アンコちゃん側でアンケートの体裁を変更して表示させていますが、プラグイン側で簡単にアンケート結果を取り出すことができます。
/vote showresultをトリガとして、下記の値がセットされます。
以下は、簡易アンケートプラグインの表示モードで、グラフに表示させるときのコードです
/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)
- 主かどうか
- オリジナルアラートの作り方
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 って感じでカンマ区切りで入ってきます。
コメントをかく