📄 cmdsepa.java
字号:
/**
* Copyright (C) 2003 Manfred Andres
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Created on 28.09.2003
*/
package freecs.commands;
import freecs.Server;
import freecs.interfaces.ICommand;
import freecs.interfaces.IGroupState;
import freecs.interfaces.IUserRights;
import freecs.core.Group;
import freecs.core.GroupManager;
import freecs.content.MessageState;
/**
* @author Manfred Andres
*
* freecs.commands
*/
public class CmdSepa implements ICommand {
public String cmd= "/sepa";
private static CmdSepa selve=null;
private CommandSet cs;
private CmdSepa () { }
private CmdSepa (CommandSet cs) {
this.cs=cs;
}
public static ICommand getInstance (CommandSet cs) {
if (selve == null) {
selve = new CmdSepa (cs);
}
return selve;
}
public boolean execute (MessageState msgState, String param) {
if (cs.isPunished (msgState))
return false;
if (param.length () < 1) {
msgState.msgTemplate = "error.sepa.noArg";
msgState.sender.sendMessage (msgState.mp);
return false;
}
int pos = param.indexOf (":");
String joinGroup;
String topic = "";
if (pos > -1) {
joinGroup = param.substring (0,pos).trim();
topic = param.substring (pos+1).trim();
} else {
joinGroup = param;
}
if (joinGroup.length() > 255)
joinGroup = joinGroup.substring (0,255);
msgState.target = joinGroup;
if (joinGroup.equalsIgnoreCase ("exil") ||
!msgState.sender.hasRight (IUserRights.MAY_OPEN_GROUP)) {
msgState.msgTemplate = "error.sepa.noRight";
msgState.sender.sendMessage (msgState.mp);
return false;
}
Group sg = msgState.sender.getGroup ();
if (sg != null)
msgState.source = sg.getName ();
else
msgState.source = "?";
if (msgState.source.equalsIgnoreCase (joinGroup)) {
msgState.msgTemplate = "error.sepa.alreadyHere";
msgState.sender.sendMessage (msgState.mp);
return false;
}
Group g = GroupManager.mgr.getGroup (joinGroup);
if (g != null) {
msgState.msgTemplate = "error.sepa.exists";
msgState.sender.sendMessage (msgState.mp);
return false;
}
g = GroupManager.mgr.openGroup (joinGroup, topic, msgState.sender);
if (g == null) {
msgState.msgTemplate = "error.sepa.noRight";
msgState.sender.sendMessage (msgState.mp);
return false;
} else if (Server.srv.isStartingGroup (g)) {
msgState.msgTemplate = "error.sepa.noRight";
msgState.sender.sendMessage (msgState.mp);
return false;
}
g.unsetState (IGroupState.OPEN);
msgState.msgTemplate = "message.sepa";
sg.sendModeraedMessage (msgState.mp);
msgState.msgTemplate = "message.sepa.confirm";
msgState.sender.sendMessage (msgState.mp);
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -