| 109 | | |
| | 109 | |
| | 110 | [Description("グループ(チャンネル)を新規作成します")] |
| | 111 | public void New([Description("新しいグループ名")]String newChannelName) |
| | 112 | { |
| | 113 | if (!CheckNewChannelName(newChannelName)) |
| | 114 | return; |
| | 115 | |
| | 116 | // 新チャンネルにJOIN |
| | 117 | Group g = new Group(newChannelName); |
| | 118 | CurrentSession.Groups.Add(newChannelName, g); |
| | 119 | CurrentSession.JoinChannel(CurrentSession, g); |
| | 120 | Console.NotifyMessage(String.Format("グループ名 {0} を作成しました。", newChannelName)); |
| | 121 | |
| | 122 | CurrentSession.SaveGroups(); |
| | 123 | } |
| | 124 | |
| | 125 | [Description("指定したグループ(チャンネル)を削除します")] |
| | 126 | public void Delete([Description("削除するグループ名")]String oldChannelName) |
| | 127 | { |
| | 128 | if (!CurrentSession.Groups.ContainsKey(oldChannelName)) |
| | 129 | { |
| | 130 | Console.NotifyMessage("エラー: 指定されたグループは見つかりませんでした。"); |
| | 131 | return; |
| | 132 | } |
| | 133 | |
| | 134 | |
| | 135 | // 旧チャンネルをPART |
| | 136 | CurrentSession.SendServer(new PartMessage(oldChannelName, "")); |
| | 137 | // 削除 |
| | 138 | CurrentSession.Groups.Remove(oldChannelName); |
| | 139 | Console.NotifyMessage(String.Format("グループ名 {0} を削除しました。", oldChannelName)); |
| | 140 | |
| | 141 | CurrentSession.SaveGroups(); |
| | 142 | } |
| | 143 | |
| 140 | | if (String.Compare(oldChannelName, newChannelName, true) == 0) |
| 141 | | { |
| 142 | | Console.NotifyMessage("エラー: 新しいグループ名と古いグループ名を同じにすることはできません。"); |
| 143 | | return false; |
| 144 | | } |
| 145 | | |
| 146 | | if (CurrentSession.Groups.ContainsKey(newChannelName) || String.Compare(CurrentSession.Config.ChannelName, newChannelName, true) == 0) |
| 147 | | { |
| 148 | | Console.NotifyMessage("エラー: 既に存在するグループ名を指定することは出来ません。"); |
| 149 | | return false; |
| 150 | | } |
| 151 | | |
| 152 | | if (!(oldChannelName.StartsWith("#") && oldChannelName.Length > 2)) |
| 153 | | { |
| 154 | | Console.NotifyMessage("エラー: グループ(チャンネル)名は#で始まる必要があります。"); |
| 155 | | return false; |
| 156 | | } |
| 157 | | |
| 158 | | return true; |
| | 190 | return CheckNewChannelName(newChannelName); |