All pastes #987521 Raw Edit

sitebot.java

public java v1 · immutable
·published 2008-04-16 16:14 UTC
rendered paste body
    private void actionPerformedInvite(InviteEvent event) throws FormatterException {        String nick = event.getIrcNick();        ReplacerEnvironment env = new ReplacerEnvironment(GLOBAL_ENV);        env.add("user",event.getUser());        env.add("nick",event.getIrcNick());		env.add("group",event.getUser().getGroup());                if ("INVITE".equals(event.getCommand()) ||        		"SITE INVITE".equals(event.getCommand())) {            ReplacerFormat format = ReplacerUtils.finalFormat(SiteBot.class,"invite.success");            logger.info("Invited " + nick);	    if((_ircwelcome)!=null)	     notice(nick, _ircwelcome);        	for (Enumeration e = getIRCConnection().getClientState().getChannels();            	e.hasMoreElements();) {            	Channel chan = (Channel) e.nextElement();            	if (chan.findMember(getIRCConnection().getClientState().getNick()                                    .getNick()).hasOps()) {            		ChannelConfig cc = _channelMap.get(chan.getName());            		if (cc != null) {            			if (cc.checkPerms(event.getUser())) {            				_conn.sendCommand(new InviteCommand(nick, chan.getName()));            	    		if (_inviteEventChannel==null)                            		say(chan.getName(),SimplePrintf.jprintf(format, env));                          	else                             		say(_inviteEventChannel, SimplePrintf.jprintf(format, env));             	    		try {					if(_noticekey.equalsIgnoreCase("true"))            	    			notice(nick, "Channel key for " + chan.getName() + " is " + cc.getChannelKey(event.getUser()));            	    		} catch (ObjectNotFoundException execption) {            	    			// no key or not enough permissions            	    		}            			} else {            				logger.warn("User does not have enough permissions to invite into " + chan.getName());            			}            		} else {            			logger.error("Could not find ChannelConfig for " + chan.getName() + " this is a bug, please report it!", new Throwable());            		}            	}            }         if (chanReturn.length()>0) {           env.add("channel",chanReturn);           say(_inviteEventChannel, SimplePrintf.jprintf(format, env));		}        	synchronized (_identWhoisList) {        		_identWhoisList.add(new WhoisEntry(nick,event.getUser()));        	}            logger.info("Looking up "+ nick + " to set IRCIdent");            _conn.sendCommand(new WhoisCommand(nick));        	        } else if ("BINVITE".equals(event.getCommand())) {            ReplacerFormat format = ReplacerUtils.finalFormat(SiteBot.class,"invite.failed");                if (_inviteEventChannel==null)    		  sayGlobal(SimplePrintf.jprintf(format, env));                else                  say(_inviteEventChannel, SimplePrintf.jprintf(format, env));     	        }            }