using System;
using Codeplex.Data;
namespace GaoLib.Twitter.Streaming
{
public class StreamEvents
{
private EventType eventTypeIns;
public delegate void StreamEventHandler(Auth auth, dynamic json);
private enum EventType
{
UNKNOWN,
ERROR,
FRIEND_ID_LIST,
I_TWEETED,
YOU_TWEETED,
I_REPLIED_TO_YOU,
I_REPLIED_TO_ME,
YOU_REPLIED_TO_ANOTHER,
YOU_REPLIED_TO_ME,
I_FAVORITED_YOU,
I_FAVORITED_ME,
YOU_FAVORITED_ME,
DELETED_I_FAVORITED_YOU,
DELETED_I_FAVORITED_ME,
DELETED_YOU_FAVORITED_ME,
I_RETWEETED_YOU,
YOU_RETWEETED_YOU,
YOU_RETWEETED_ME,
DELETED_I_TWEETED_OR_REPLIED_OR_RETWEETED,
DELETED_YOU_TWEETED_OR_REPLIED_OR_RETWEETED,
I_SENDED_DIRECT_MESSAGE_TO_YOU,
YOU_SENDED_DIRECT_MESSAGE_TO_ME,
DELETED_I_SENDED_DIRECT_MESSAGE_TO_YOU,
I_FOLLOWED_YOU,
YOU_FOLLOWED_ME,
I_REMOVED_YOU,
I_BLOCKED_YOU,
DELETED_I_BLOCKED_YOU,
I_UPDATED_MY_PROFILE,
I_REVOKED_APPLET_ACCESS,
DELETED_I_REVOKED_APPLET_ACCESS,
DELETED_MY_SCRUB_GEO,
DELETED_YOUR_SCRUB_GEO,
I_CREATED_MY_PUBLIC_LIST,
I_UPDATED_MY_PUBLIC_LIST,
I_ADDED_YOU_TO_MY_PUBLIC_LIST,
I_ADDED_ME_TO_MY_PUBLIC_LIST,
YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST,
I_SAVED_YOUR_PUBLIC_LIST,
YOU_SAVED_MY_PUBLIC_LIST,
DELETED_I_CREATED_MY_PUBLIC_LIST,
DELETED_I_ADDED_YOU_TO_MY_PUBLIC_LIST,
DELETED_I_ADDED_ME_TO_MY_PUBLIC_LIST,
DELETED_YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST,
DELETED_I_SAVED_YOUR_PUBLIC_LIST,
DELETED_YOU_SAVED_MY_PUBLIC_LIST,
};
public StreamEventHandler RawJSONOutput;
public StreamEventHandler IncludeURL;
public StreamEventHandler FriendIdList;
public StreamEventHandler ITweeted;
public StreamEventHandler YouTweeted;
public StreamEventHandler IRepliedToYou;
public StreamEventHandler IRepliedToMe;
public StreamEventHandler YouRepliedToAnother;
public StreamEventHandler YouRepliedToMe;
public StreamEventHandler IFavoritedYou;
public StreamEventHandler IFavoritedMe;
public StreamEventHandler YouFavoritedMe;
public StreamEventHandler DeletedIFavoritedYou;
public StreamEventHandler DeletedIFavoritedMe;
public StreamEventHandler DeletedYouFavoritedMe;
public StreamEventHandler IRetweetedYou;
public StreamEventHandler YouRetweetedAnother;
public StreamEventHandler YouRetweetedMe;
public StreamEventHandler DeletedITweetedOrRepliedOrRetweeted;
public StreamEventHandler DeletedYouTweetedOrRepliedOrRetweeted;
public StreamEventHandler ISendedDirectMessageToYou;
public StreamEventHandler YouSendedDirectMessageToMe;
public StreamEventHandler DeletedISendedDirectMessageToYou;
public StreamEventHandler IFollowedYou;
public StreamEventHandler YouFollowedMe;
public StreamEventHandler IRemovedYou;
public StreamEventHandler IBlockedYou;
public StreamEventHandler DeletedIBlockedYou;
public StreamEventHandler IUpdatedMyProfile;
public StreamEventHandler IRevokedAppletAccess;
public StreamEventHandler DeletedIRevokedAppletAccess;
public StreamEventHandler DeletedMyScrubGeo;
public StreamEventHandler DeletedYourScrubGeo;
public StreamEventHandler ICreatedMyPublicList;
public StreamEventHandler IUpdatedMyPublicList;
public StreamEventHandler IAddedYouToMyPublicList;
public StreamEventHandler IAddedMeToMyPublicList;
public StreamEventHandler YouAddedMeToYourPublicList;
public StreamEventHandler ISavedYourPublicList;
public StreamEventHandler YouSavedMyPublicList;
public StreamEventHandler DeletedICreatedMyPublicList;
public StreamEventHandler DeletedIAddedYouToMyPublicList;
public StreamEventHandler DeletedIAddedMeToMyPublicList;
public StreamEventHandler DeletedYouAddedMeToYourPublicList;
public StreamEventHandler DeletedISavedYourPublicList;
public StreamEventHandler DeletedYouSavedMyPublicList;
public StreamEvents()
{
eventTypeIns = new EventType();
//もっとスマートな初期化方法ないのかな?
RawJSONOutput = (a, b) => { };
IncludeURL = (a, b) => { };
FriendIdList = (a, b) => { };
ITweeted = (a, b) => { };
YouTweeted = (a, b) => { };
DeletedMyScrubGeo = (a, b) => { };
DeletedYourScrubGeo = (a, b) => { };
IFavoritedYou = (a, b) => { };
IFavoritedMe = (a, b) => { };
YouFavoritedMe = (a, b) => { };
IRetweetedYou = (a, b) => { };
YouRetweetedAnother = (a, b) => { };
YouRetweetedMe = (a, b) => { };
DeletedITweetedOrRepliedOrRetweeted = (a, b) => { };
DeletedYouTweetedOrRepliedOrRetweeted = (a, b) => { };
IRepliedToYou = (a, b) => { };
IRepliedToMe = (a, b) => { };
YouRepliedToAnother = (a, b) => { };
YouRepliedToMe = (a, b) => { };
ISendedDirectMessageToYou = (a, b) => { };
YouSendedDirectMessageToMe = (a, b) => { };
IFollowedYou = (a, b) => { };
YouFollowedMe = (a, b) => { };
IUpdatedMyProfile = (a, b) => { };
DeletedIFavoritedYou = (a, b) => { };
DeletedIFavoritedMe = (a, b) => { };
DeletedYouFavoritedMe = (a, b) => { };
DeletedISendedDirectMessageToYou = (a, b) => { };
IRemovedYou = (a, b) => { };
IBlockedYou = (a, b) => { };
DeletedIBlockedYou = (a, b) => { };
ICreatedMyPublicList = (a, b) => { };
DeletedICreatedMyPublicList = (a, b) => { };
IUpdatedMyPublicList = (a, b) => { };
IAddedYouToMyPublicList = (a, b) => { };
IAddedMeToMyPublicList = (a, b) => { };
DeletedIAddedYouToMyPublicList = (a, b) => { };
DeletedIAddedMeToMyPublicList = (a, b) => { };
YouAddedMeToYourPublicList = (a, b) => { };
DeletedYouAddedMeToYourPublicList = (a, b) => { };
ISavedYourPublicList = (a, b) => { };
DeletedISavedYourPublicList = (a, b) => { };
YouSavedMyPublicList = (a, b) => { };
DeletedYouSavedMyPublicList = (a, b) => { };
IRevokedAppletAccess = (a, b) => { };
DeletedIRevokedAppletAccess = (a, b) => { };
}
public void CheckOnEvent(Auth auth,dynamic json){
try
{
eventTypeIns = GetEventType(auth, json);
}
catch (Exception error)
{
Console.WriteLine(error.Source + " : " + error.Message);
eventTypeIns = EventType.ERROR;
}
switch (eventTypeIns)
{
case EventType.FRIEND_ID_LIST:
FriendIdList(auth,json);
break;
case EventType.I_TWEETED:
ITweeted(auth, json);
break;
case EventType.YOU_TWEETED:
YouTweeted(auth, json);
break;
case EventType.I_FAVORITED_YOU:
IFavoritedYou(auth,json);
break;
case EventType.I_FAVORITED_ME:
IFavoritedMe(auth,json);
break;
case EventType.YOU_FAVORITED_ME:
YouFavoritedMe(auth,json);
break;
case EventType.I_RETWEETED_YOU:
IRetweetedYou(auth,json);
break;
case EventType.YOU_RETWEETED_YOU:
YouRetweetedAnother(auth,json);
break;
case EventType.YOU_RETWEETED_ME:
YouRetweetedMe(auth,json);
break;
case EventType.DELETED_I_TWEETED_OR_REPLIED_OR_RETWEETED:
DeletedITweetedOrRepliedOrRetweeted(auth,json);
break;
case EventType.DELETED_YOU_TWEETED_OR_REPLIED_OR_RETWEETED:
DeletedYouTweetedOrRepliedOrRetweeted(auth,json);
break;
case EventType.I_REPLIED_TO_YOU:
IRepliedToYou(auth,json);
break;
case EventType.I_REPLIED_TO_ME:
IRepliedToMe(auth,json);
break;
case EventType.YOU_REPLIED_TO_ANOTHER:
YouRepliedToAnother(auth,json);
break;
case EventType.YOU_REPLIED_TO_ME:
YouRepliedToMe(auth,json);
break;
case EventType.I_SENDED_DIRECT_MESSAGE_TO_YOU:
ISendedDirectMessageToYou(auth,json);
break;
case EventType.YOU_SENDED_DIRECT_MESSAGE_TO_ME:
YouSendedDirectMessageToMe(auth,json);
break;
case EventType.I_FOLLOWED_YOU:
IFollowedYou(auth,json);
break;
case EventType.YOU_FOLLOWED_ME:
YouFollowedMe(auth,json);
break;
case EventType.I_UPDATED_MY_PROFILE:
IUpdatedMyProfile(auth,json);
break;
case EventType.DELETED_I_FAVORITED_YOU:
DeletedIFavoritedYou(auth,json);
break;
case EventType.DELETED_I_FAVORITED_ME:
DeletedIFavoritedMe(auth,json);
break;
case EventType.DELETED_YOU_FAVORITED_ME:
DeletedYouFavoritedMe(auth,json);
break;
case EventType.DELETED_I_SENDED_DIRECT_MESSAGE_TO_YOU:
DeletedISendedDirectMessageToYou(auth,json);
break;
case EventType.I_REMOVED_YOU:
IRemovedYou(auth,json);
break;
case EventType.I_BLOCKED_YOU:
IBlockedYou(auth,json);
break;
case EventType.DELETED_I_BLOCKED_YOU:
DeletedIBlockedYou(auth,json);
break;
case EventType.I_CREATED_MY_PUBLIC_LIST:
ICreatedMyPublicList(auth,json);
break;
case EventType.DELETED_I_CREATED_MY_PUBLIC_LIST:
DeletedICreatedMyPublicList(auth,json);
break;
case EventType.I_UPDATED_MY_PUBLIC_LIST:
IUpdatedMyPublicList(auth,json);
break;
case EventType.I_ADDED_YOU_TO_MY_PUBLIC_LIST:
IAddedYouToMyPublicList(auth,json);
break;
case EventType.I_ADDED_ME_TO_MY_PUBLIC_LIST:
IAddedMeToMyPublicList(auth,json);
break;
case EventType.DELETED_I_ADDED_YOU_TO_MY_PUBLIC_LIST:
DeletedIAddedYouToMyPublicList(auth,json);
break;
case EventType.DELETED_I_ADDED_ME_TO_MY_PUBLIC_LIST:
DeletedIAddedMeToMyPublicList(auth,json);
break;
case EventType.YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST:
YouAddedMeToYourPublicList(auth,json);
break;
case EventType.DELETED_YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST:
DeletedYouAddedMeToYourPublicList(auth,json);
break;
case EventType.I_SAVED_YOUR_PUBLIC_LIST:
ISavedYourPublicList(auth,json);
break;
case EventType.DELETED_I_SAVED_YOUR_PUBLIC_LIST:
DeletedISavedYourPublicList(auth,json);
break;
case EventType.YOU_SAVED_MY_PUBLIC_LIST:
YouSavedMyPublicList(auth,json);
break;
case EventType.DELETED_YOU_SAVED_MY_PUBLIC_LIST:
DeletedYouSavedMyPublicList(auth,json);
break;
case EventType.I_REVOKED_APPLET_ACCESS:
IRevokedAppletAccess(auth,json);
break;
case EventType.DELETED_I_REVOKED_APPLET_ACCESS:
DeletedIRevokedAppletAccess(auth,json);
break;
case EventType.DELETED_MY_SCRUB_GEO:
DeletedMyScrubGeo(auth, json);
break;
case EventType.DELETED_YOUR_SCRUB_GEO:
DeletedMyScrubGeo(auth, json);
break;
//わからないものは、触れないことにする。
case EventType.UNKNOWN:
Console.WriteLine("EventType.UNKNOWNだったのでスルーしました");
break;
//エラー吐いても、スルーして次へ
case EventType.ERROR:
Console.WriteLine("EventType.ERRORだったけどStreamingを一応続けるね");
break;
default:
throw new Exception("不明なEventTypeでした。(EventType : "+eventTypeIns.ToString());
}
if (json.IsDefined("entities") && json["entities"].IsDefined("urls") && json["entities"]["urls"] != null)
{
//URL付きツイート
IncludeURL(auth,json);
}
RawJSONOutput(auth, json);
Console.WriteLine(eventTypeIns.ToString());
}
private EventType GetEventType(Auth auth,dynamic json)
{
//イベント系かどうか
if (json.IsDefined("event"))
{
string eventType = json["event"].ToString();
switch (eventType)
{
case "favorite":
if ((auth.UserId == json["target"]["id_str"]) && (auth.UserId == json["source"]["id_str"]))
{
//自演ふぁぼ
return EventType.I_FAVORITED_ME;
}
else if (auth.UserId == json["source"]["id_str"])
{
//他人ふぁぼ
return EventType.I_FAVORITED_YOU;
}
else if (auth.UserId == json["target"]["id_str"])
{
//ふぁぼられ
return EventType.YOU_FAVORITED_ME;
}
else
{
//????
throw new Exception("ふぁぼふぁぼ関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "unfavorite":
if ((auth.UserId == json["target"]["id_str"]) && (auth.UserId == json["source"]["id_str"]))
{
//自演ふぁぼリム
return EventType.DELETED_I_FAVORITED_ME;
}
else if (auth.UserId == json["source"]["id_str"])
{
//他人ふぁぼリム
return EventType.DELETED_I_FAVORITED_YOU;
}
else if (auth.UserId == json["target"]["id_str"])
{
//ふぁぼられリム
return EventType.DELETED_YOU_FAVORITED_ME;
}
else
{
//????
throw new Exception("ふぁぼリム関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "follow":
if (auth.UserId == json["source"]["id_str"])
{
//こっちがフォロー
return EventType.I_FOLLOWED_YOU;
}
else if (auth.UserId == json["target"]["id_str"])
{
//相手からのフォロー
return EventType.YOU_FOLLOWED_ME;
}
else
{
//????
throw new Exception("フォロー関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "unfollow":
if (auth.UserId == json["source"]["id_str"])
{
//こっちがリムーブ・・・なんだけど
//----*注意!*----
//この結果は、Twitter社の陰謀で、
//①自分が相手をリムーブ
//②相手をフォロー時に自分が相手をブロック
//③自分が相手にブロックされる
//上記のどの条件でも発動します。注意されたし。
return EventType.I_REMOVED_YOU;
}
else
{
//????
throw new Exception("unfollowリムブロ関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "block":
if (auth.UserId == json["source"]["id_str"])
{
return EventType.I_BLOCKED_YOU;
}
else
{
//????
throw new Exception("blockブロック関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "unblock":
if (auth.UserId == json["source"]["id_str"])
{
return EventType.DELETED_I_BLOCKED_YOU;
}
else
{
//????
throw new Exception("unblockアンブロック関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_created":
if (auth.UserId == json["source"]["id_str"])
{
return EventType.I_CREATED_MY_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リスト作成関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_destroyed":
if (auth.UserId == json["source"]["id_str"])
{
return EventType.DELETED_I_CREATED_MY_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リスト削除関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_updated":
if (auth.UserId == json["source"]["id_str"])
{
return EventType.I_UPDATED_MY_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リスト削除関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_member_added":
if ((auth.UserId == json["source"]["id_str"]) && (auth.UserId == json["target"]["id_str"]))
{
//自作リストに自分を追加させた
return EventType.I_ADDED_ME_TO_MY_PUBLIC_LIST;
}
else if (auth.UserId == json["source"]["id_str"])
{
//自作リストに他人を追加した
return EventType.I_ADDED_YOU_TO_MY_PUBLIC_LIST;
}
else if (auth.UserId == json["target"]["id_str"])
{
//他人のリストに自分が追加された
return EventType.YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リストメンバー追加関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_member_removed":
if ((auth.UserId == json["source"]["id_str"]) && (auth.UserId == json["target"]["id_str"]))
{
//自作リストから自分を除外した
return EventType.DELETED_I_ADDED_ME_TO_MY_PUBLIC_LIST;
}
else if (auth.UserId == json["source"]["id_str"])
{
//自作リストから他人を除外した
return EventType.DELETED_I_ADDED_YOU_TO_MY_PUBLIC_LIST;
}
else if (auth.UserId == json["target"]["id_str"])
{
//他人のリストから自分が除外された
return EventType.DELETED_YOU_ADDED_ME_TO_YOUR_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リストメンバー除外関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_user_subscribed":
if (auth.UserId == json["source"]["id_str"])
{
//自分が相手のリストを保存した
return EventType.I_SAVED_YOUR_PUBLIC_LIST;
}
else if (auth.UserId == json["target"]["id_str"])
{
//他人が自分のリストを保存した
return EventType.YOU_SAVED_MY_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リスト保存関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "list_user_unsubscribed":
if (auth.UserId == json["source"]["id_str"])
{
//自分が相手のリストを保存を解除した
return EventType.DELETED_I_SAVED_YOUR_PUBLIC_LIST;
}
else if (auth.UserId == json["target"]["id_str"])
{
//他人が自分のリストを保存を解除した
return EventType.DELETED_YOU_SAVED_MY_PUBLIC_LIST;
}
else
{
//????
throw new Exception("リスト保存関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "access_revoked":
if (auth.UserId == json["source"]["id_str"])
{
//自分が自分でアプリ連携の許可を取り消した
return EventType.I_REVOKED_APPLET_ACCESS;
}
else
{
//????
throw new Exception("アプリ連携取り消し関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
case "access_unrevoked":
if (auth.UserId == json["source"]["id_str"])
{
//自分が自分でアプリ連携の許可を取り消したをやめた(日本語おかしい)
return EventType.DELETED_I_REVOKED_APPLET_ACCESS;
}
else
{
//????
throw new Exception("アプリ連携取り消しの取り消し関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["source"]["id_str"] + ",target:" + json["target"]["id_str"] + ")");
}
default:
Console.WriteLine("不明なevent名 : " + eventType);
return EventType.UNKNOWN;
}
}
else
{
if (json.IsDefined("retweeted_status"))
{
if ((auth.UserId != json["retweeted_status"]["user"]["id_str"]) && (auth.UserId != json["user"]["id_str"]))
{
//他人⇒他人
return EventType.YOU_RETWEETED_YOU;
}
else if (auth.UserId != json["retweeted_status"]["user"]["id_str"])
{
//自分⇒他人
return EventType.I_RETWEETED_YOU;
}
else if (auth.UserId != json["user"]["id_str"])
{
//他人⇒自分
return EventType.YOU_RETWEETED_ME;
}
else
{
//????
throw new Exception("RT関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["user"]["id_str"] + ",target:" + json["retweeted_status"]["user"]["id_str"] + ")");
}
}
else if (json.IsDefined("direct_message"))
{
if (auth.UserId == json["direct_message"]["sender"]["id_str"])
{
//DM送った
return EventType.I_SENDED_DIRECT_MESSAGE_TO_YOU;
}
else if (auth.UserId == json["direct_message"]["recipient"]["id_str"])
{
//DM受け取った
return EventType.YOU_SENDED_DIRECT_MESSAGE_TO_ME;
}
else
{
//????
throw new Exception("DM関係で謎の状態に陥った(auth:" + auth.UserId + ",sender:" + auth.UserId == json["direct_message"]["sender"]["id_str"] + ",recipient:" + json["direct_message"]["recipient"]["id_str"] + ")");
}
}
else if (json.IsDefined("delete"))
{
if (json["delete"].IsDefined("status"))
{
if (auth.UserId == json["delete"]["status"]["user_id_str"])
{
//自分のメッセージを消した(ツイ消し・リプ消し・RT取り消し)
return EventType.DELETED_I_TWEETED_OR_REPLIED_OR_RETWEETED;
}
else
{
//相手がメッセージを消した(ツイ消し・リプ消し・RT取り消し)
return EventType.DELETED_YOU_TWEETED_OR_REPLIED_OR_RETWEETED;
}
}
else if (json["delete"].IsDefined("direct_message"))
{
if (auth.UserId == json["delete"]["direct_message"]["user_id"].ToString()) //user_id_strはない。バグ?
{
//自分or相手が自分のDMを消した
return EventType.DELETED_I_SENDED_DIRECT_MESSAGE_TO_YOU;
}
else
{
//????
throw new Exception("DM削除関係で謎の状態に陥った(auth:" + auth.UserId + ",target:" + json["delete"]["direct_message"]["user_id"] + ")");
}
}
else
{
//????
throw new Exception("削除関係で謎の状態に陥った(auth:" + auth.UserId + ")");
}
}
else if (json.IsDefined("scrub_geo"))
{
if (auth.UserId == json["scrub_geo"]["user_id_str"])
{
//自分が自分の位置情報を消した
return EventType.DELETED_MY_SCRUB_GEO;
}
else
{
//他人が他人の位置情報を消した
return EventType.DELETED_YOUR_SCRUB_GEO;
}
}
else if (json.IsDefined("text"))
{
if (json.IsDefined("in_reply_to_user_id_str") && json["in_reply_to_user_id_str"] != null)
{
//リプライ
if ((auth.UserId == json["in_reply_to_user_id_str"]) && (auth.UserId == json["user"]["id_str"]))
{
//自分⇒自分
return EventType.I_REPLIED_TO_ME;
}
else if ((auth.UserId != json["in_reply_to_user_id_str"]) && (auth.UserId != json["user"]["id_str"]))
{
//他人⇒他人
return EventType.YOU_REPLIED_TO_ANOTHER;
}
else if (auth.UserId != json["in_reply_to_user_id_str"])
{
//自分⇒他人
return EventType.I_REPLIED_TO_YOU;
}
else if (auth.UserId != json["user"]["id_str"])
{
//他人⇒自分
return EventType.YOU_REPLIED_TO_ME;
}
else
{
//????
throw new Exception("リプライ関係で謎の状態に陥った(auth:" + auth.UserId + ",source:" + json["user"]["id_str"] + ",target:" + json["in_reply_to_user_id_str"] + ")");
}
}
else
{
//多分通常ツイート
if (auth.UserId == json["user"]["id_str"])
{
//自分のつぶやき
return EventType.I_TWEETED;
}
else
{
//他人のつぶやき
return EventType.YOU_TWEETED;
}
}
}
else if (json.IsDefined("friends"))
{
//一番最初にだけやってくるfriendリスト
return EventType.FRIEND_ID_LIST;
}
else
{
//よくわからんのが来た
return EventType.UNKNOWN;
}
}
}
}
}