Changeset 367
- Timestamp:
- 03/16/08 19:02:56 (10 months ago)
- Location:
- TwitterIrcGateway
- Files:
-
- 7 modified
-
TwitterIrcGateway/App.config (modified) (1 diff)
-
TwitterIrcGateway/Program.cs (modified) (1 diff)
-
TwitterIrcGateway/Settings.Designer.cs (modified) (2 diffs)
-
TwitterIrcGateway/Settings.settings (modified) (1 diff)
-
TwitterIrcGatewayCLI/Program.cs (modified) (3 diffs)
-
TwitterIrcGatewayCore/Server.cs (modified) (1 diff)
-
TwitterIrcGatewayCore/Session.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
TwitterIrcGateway/TwitterIrcGateway/App.config
r364 r367 56 56 <value>False</value> 57 57 </setting> 58 <setting name="ClientMessageWait" serializeAs="String"> 59 <value>0</value> 60 </setting> 58 61 </Misuzilla.Applications.TwitterIrcGateway.Settings> 59 62 </userSettings> -
TwitterIrcGateway/TwitterIrcGateway/Program.cs
r364 r367 60 60 _server.DisableUserList = _settings.DisableUserList; 61 61 _server.BroadcastUpdate = _settings.BroadcastUpdate; 62 _server.ClientMessageWait = _settings.ClientMessageWait; 62 63 _server.SessionStartedRecieved += new EventHandler<SessionStartedEventArgs>(_server_SessionStartedRecieved); 63 64 try -
TwitterIrcGateway/TwitterIrcGateway/Settings.Designer.cs
r364 r367 2 2 // <auto-generated> 3 3 // このコードはツールによって生成されました。 4 // ランタイム バージョン:2.0.50727.143 34 // ランタイム バージョン:2.0.50727.1434 5 5 // 6 6 // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 … … 215 215 } 216 216 } 217 218 [global::System.Configuration.UserScopedSettingAttribute()] 219 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 220 [global::System.Configuration.DefaultSettingValueAttribute("0")] 221 public int ClientMessageWait { 222 get { 223 return ((int)(this["ClientMessageWait"])); 224 } 225 set { 226 this["ClientMessageWait"] = value; 227 } 228 } 217 229 } 218 230 } -
TwitterIrcGateway/TwitterIrcGateway/Settings.settings
r364 r367 51 51 <Value Profile="(Default)">False</Value> 52 52 </Setting> 53 <Setting Name="ClientMessageWait" Type="System.Int32" Scope="User"> 54 <Value Profile="(Default)">0</Value> 55 </Setting> 53 56 </Settings> 54 57 </SettingsFile> -
TwitterIrcGateway/TwitterIrcGatewayCLI/Program.cs
r364 r367 57 57 _server.DisableUserList = options.DisableUserlist; 58 58 _server.BroadcastUpdate = options.BroadcastUpdate; 59 _server.ClientMessageWait = options.ClientMessageWait; 59 60 _server.SessionStartedRecieved += new EventHandler<SessionStartedEventArgs>(_server_SessionStartedRecieved); 60 61 … … 75 76 Console.WriteLine("[Configuration] DisableUserList: {0}", _server.DisableUserList); 76 77 Console.WriteLine("[Configuration] BroadcastUpdate: {0}", _server.BroadcastUpdate); 78 Console.WriteLine("[Configuration] ClientMessageWait: {0}", _server.ClientMessageWait); 77 79 78 80 _server.Start(bindAddress, options.Port); … … 160 162 [Description("broadcast status message on updated")] 161 163 public Boolean BroadcastUpdate { get; set; } 164 165 [DefaultValue(0)] 166 [Description("wait of send messages to client (milliseconds)")] 167 public Int32 ClientMessageWait { get; set; } 162 168 } 163 169 } -
TwitterIrcGateway/TwitterIrcGatewayCore/Server.cs
r364 r367 78 78 /// </summary> 79 79 public Boolean BroadcastUpdate = false; 80 81 /// <summary> 82 /// �N���C�A���g�Ƀ��b�Z�[�W�𑗐M�������̃E�F�C�g 83 /// </summary> 84 public Int32 ClientMessageWait = 0; 80 85 81 86 public const String ServerName = "localhost"; -
TwitterIrcGateway/TwitterIrcGatewayCore/Session.cs
r364 r367 1135 1135 if (_isFirstTime) 1136 1136 { 1137 NoticeMessage noticeMsg = new NoticeMessage(); 1138 noticeMsg.SenderNick = status.User.ScreenName; 1139 noticeMsg.SenderHost = "twitter@" + Server.ServerName; 1140 noticeMsg.Receiver = _server.ChannelName; 1141 noticeMsg.Content = String.Format("{0}: {1}", status.CreatedAt.ToString("HH:mm"), line); 1142 Send(noticeMsg); 1137 Send(new NoticeMessage() 1138 { 1139 SenderNick = status.User.ScreenName, 1140 SenderHost = "twitter@" + Server.ServerName, 1141 Receiver = _server.ChannelName, 1142 Content = String.Format("{0}: {1}", status.CreatedAt.ToString("HH:mm"), line) 1143 }); 1143 1144 } 1144 1145 else 1145 1146 { 1146 IRCMessage msg; 1147 switch (filterArgs.IRCMessageType.ToUpperInvariant()) 1148 { 1149 case "NOTICE": 1150 msg = new NoticeMessage(_server.ChannelName, line); 1151 break; 1152 case "PRIVMSG": 1153 default: 1154 msg = new PrivMsgMessage(_server.ChannelName, line); 1155 break; 1156 } 1157 msg.SenderNick = status.User.ScreenName; 1158 msg.SenderHost = "twitter@" + Server.ServerName; 1159 Send(msg); 1160 1161 // グループにも投げる 1162 foreach (Group group in _groups.Values) 1163 { 1164 if (!group.IsJoined) 1165 continue; 1166 1167 Boolean isMatched = String.IsNullOrEmpty(group.Topic) ? true : Regex.IsMatch(line, group.Topic); 1168 1169 // 1: member exists in channel && match regex 1170 // 2: no members in channel(self only) && match regex 1171 if ((group.Exists(status.User.ScreenName) || group.Members.Count == 0) && isMatched) 1147 Send(CreateIRCMessageFromStatusAndType(status, filterArgs.IRCMessageType, _server.ChannelName, line)); 1148 } 1149 1150 // グループにも投げる 1151 foreach (Group group in _groups.Values) 1152 { 1153 if (!group.IsJoined) 1154 continue; 1155 1156 Boolean isMatched = String.IsNullOrEmpty(group.Topic) ? true : Regex.IsMatch(line, group.Topic); 1157 1158 // 1: member exists in channel && match regex 1159 // 2: no members in channel(self only) && match regex 1160 if ((group.Exists(status.User.ScreenName) || group.Members.Count == 0) && isMatched) 1161 { 1162 if (_isFirstTime) 1172 1163 { 1173 switch (filterArgs.IRCMessageType.ToUpperInvariant()) 1174 { 1175 case "NOTICE": 1176 msg = new NoticeMessage(group.Name, line); 1177 break; 1178 case "PRIVMSG": 1179 default: 1180 msg = new PrivMsgMessage(group.Name, line); 1181 break; 1182 } 1183 msg.SenderNick = status.User.ScreenName; 1184 msg.SenderHost = "twitter@" + Server.ServerName; 1185 Send(msg); 1164 // 初回はNOTICE 1165 Send(CreateIRCMessageFromStatusAndType(status, "NOTICE", group.Name, String.Format("{0}: {1}", status.CreatedAt.ToString("HH:mm"), line))); 1166 } 1167 else 1168 { 1169 Send(CreateIRCMessageFromStatusAndType(status, filterArgs.IRCMessageType, group.Name, line)); 1186 1170 } 1187 1171 } … … 1205 1189 } 1206 1190 } 1191 1192 // ウェイト 1193 if (_server.ClientMessageWait > 0) 1194 Thread.Sleep(_server.ClientMessageWait); 1195 } 1196 1197 // XXX: IRCクライアントライブラリのアップデートで対応できるけどとりあえず... 1198 private IRCMessage CreateIRCMessageFromStatusAndType(Status status, String type, String receiver, String line) 1199 { 1200 IRCMessage msg; 1201 switch (type.ToUpperInvariant()) 1202 { 1203 case "NOTICE": 1204 msg = new NoticeMessage(receiver, line); 1205 break; 1206 case "PRIVMSG": 1207 default: 1208 msg = new PrivMsgMessage(receiver, line); 1209 break; 1210 } 1211 msg.SenderNick = status.User.ScreenName; 1212 msg.SenderHost = "twitter@" + Server.ServerName; 1213 1214 return msg; 1207 1215 } 1208 1216
