hattrickirc-commitlog Mailing List for HattrickIRC
Status: Beta
Brought to you by:
suls
You can subscribe to this list here.
2005 |
Jan
(9) |
Feb
(51) |
Mar
|
Apr
|
May
|
Jun
(36) |
Jul
(11) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(13) |
Nov
|
Dec
(2) |
From: Mathias S. <su...@us...> - 2006-12-21 10:08:56
|
Update of /cvsroot/hattrickirc/HattrickIRC/doc In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv3083/doc Modified Files: Readme.txt Log Message: commands section changed and privilegs section removed Index: Readme.txt =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/doc/Readme.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Readme.txt 8 Jul 2005 14:20:16 -0000 1.7 +++ Readme.txt 21 Dec 2006 10:08:50 -0000 1.8 @@ -1,7 +1,7 @@ *********************************************************** -Welcome to the "HattrickIRC 2.0.0-alpha" README FILE! +Welcome to the "HattrickIRC 2.0.0-alpha-R2" README FILE! *********************************************************** -June 28, 2005 +December 21, 2006 $Id$ @@ -16,10 +16,9 @@ I - REQUIREMENTS II - HOW TO START III - COMMANDS - IV - PRIVILEGES - V - SUPPORT - VI - KNOWN ISSUES - VII - THANKS + IV - SUPPORT + V - KNOWN ISSUES + VI - THANKS I - REQUIREMENTS ----------------------- @@ -52,57 +51,55 @@ e.g ! is your prefix !add must be written to perform this command - - - To add a match use the 'add' command with the Match-Id - attached. - - Example: add 309466734 - - You can add multiple matches to the viewing list but not more - than 10. - - - To remove a match from the viewing list use the 'del' - command the same way like the add-command. - - - An overview of the active matches is provided by the - 'info' command. - - - General informations about the program can be viewed by - the 'about' command. - - - If you want to quit the bot just type '!exit'. - - - To add an operator use the 'operatoradd' command - followed by the nick - - - In the same way as adding a operator use the 'operatordel' - command to remove an operator - - - To see the current list of operators and owner use the - 'botaccess' command - -IV - PRIVILEGES ---------------- -Every user in the channel is allowed to perform this command: + The term "matchid" is a placeholder for the specific match id. + + about + @access: everyone + General information about the program. - * about + add matchid + @access: operators, owner + adds the match to the bot's watchlist and prints it's infos (see + 'info' command) -Operators are allowed to perform these commands + user commands: + del matchid + @access: operators, owner + removes the match from the watchlist - * add - * del - * info - -The owner is allowed to perform these commands + operator -and user commands: + info matchid + @access: operators, owner + prints a short overview of the match: + 34': Trick 77 - Spassvogel 0 - 0 + + if no matchid is submitted, all games are printed + + allinfo + @access: operators, owner + prints more detailed overview of all the games + [23452345] 34': Trick 77 - Spassvogel 0 - 0 (Events: 5) + + report matchid + @access: operators, owner + prints the matchreport - * operatoradd - * operatordel - * botaccess - * exit + exit + @access: owner + quits the bot + + operatoradd nick + @access: owner + adds the 'nick' to the operator list + + operatordel nick + @access: owner + removes the 'nick' from the operator list + + botaccess + @access: owner + prints the bot's owner and it's operators -V - SUPPORT +IV - SUPPORT ------------ Feel free to use the help forum: @@ -111,18 +108,17 @@ .. but don't forget to post the logfile. And for your own pleasure please remove the securitycode! -VI - KNOWN ISSUES +V - KNOWN ISSUES ---------------- Because it's the first public release no bugs etc are known .. Note: some fields in the configuration aren't implemented yet. -VII - THANKS +VI - THANKS ----------- - + * Buy van der Werf - thanks a lot, really! * The hattrick.org staff who provieds the best game ever known - * Valerie Wynne who is currently my host-ma in Galway, IRL * The sf.net staff * .. and a special thanks goes to the guys from #misges at quakenet who are helping me to write HattrickIRC fool-proof ;) \ No newline at end of file |
From: Mathias S. <su...@us...> - 2006-12-21 09:35:05
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv21813/src/org/hattrick/hattrickirc/bot Modified Files: HattrickBot.java Log Message: date changed Index: HattrickBot.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/HattrickBot.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- HattrickBot.java 1 Oct 2006 17:41:07 -0000 1.7 +++ HattrickBot.java 21 Dec 2006 09:34:58 -0000 1.8 @@ -98,7 +98,7 @@ } protected void about(String sender, String[] args) { - sendMessage(ircConfig.getChannel(), "HattrickIRC Copyright (C) 2005 - Mathias Sulser <su...@su...>"); + sendMessage(ircConfig.getChannel(), "HattrickIRC Copyright (C) 2005, 2006 - Mathias Sulser <su...@su...>"); sendMessage(ircConfig.getChannel(), "This application uses information from the online game service Hattrick.org." + " This use has been approved by the developers and copyright owners of Hattrick.org, Extralives AB"); } |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:17
|
Update of /cvsroot/hattrickirc/HattrickIRC/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/test Added Files: .cvsignore Log Message: Changes from Boy van der Werf (nethyperon) --- NEW FILE: .cvsignore --- config.xml |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:14
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/net In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/net Modified Files: HattrickConnection.java Log Message: Changes from Boy van der Werf (nethyperon) Index: HattrickConnection.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/net/HattrickConnection.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- HattrickConnection.java 8 Jul 2005 14:01:57 -0000 1.10 +++ HattrickConnection.java 1 Oct 2006 17:41:07 -0000 1.11 @@ -129,26 +129,22 @@ * @param cmd Request url * @return The xml output */ - public Element performCommand(String urlFragment) { + public Element performCommand(String urlFragment) throws Exception { // TODO: make sure that a timeout won't affect the query // remember to add matches after a timeout occured logger.debug("performing command: " + urlFragment); - try { - if(hattrickServerURL == null) { - hattrickServerURL = "http://www.hattrick.org"; - } - URL requestUrl = new URL(hattrickServerURL + urlFragment); - HttpURLConnection huc = (HttpURLConnection) requestUrl.openConnection(); - huc.setRequestProperty("User-Agent", USER_AGENT); - huc.setRequestProperty("Cookie", sessionCookie); - - SAXBuilder builder = new SAXBuilder(); - Document doc = builder.build(huc.getInputStream()); - - return doc.getRootElement(); - } catch(Exception e) { - logger.error("couldn't perform the command: ", e); - } - return null; + + if(hattrickServerURL == null) { + hattrickServerURL = "http://www.hattrick.org"; + } + URL requestUrl = new URL(hattrickServerURL + urlFragment); + HttpURLConnection huc = (HttpURLConnection) requestUrl.openConnection(); + huc.setRequestProperty("User-Agent", USER_AGENT); + huc.setRequestProperty("Cookie", sessionCookie); + + SAXBuilder builder = new SAXBuilder(); + Document doc = builder.build(huc.getInputStream()); + + return doc.getRootElement(); } } \ No newline at end of file |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:14
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/bot Modified Files: HattrickBot.java Messenger.java Log Message: Changes from Boy van der Werf (nethyperon) Index: HattrickBot.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/HattrickBot.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- HattrickBot.java 8 Jul 2005 13:57:28 -0000 1.6 +++ HattrickBot.java 1 Oct 2006 17:41:07 -0000 1.7 @@ -24,6 +24,7 @@ */ package org.hattrick.hattrickirc.bot; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -33,6 +34,7 @@ import org.hattrick.hattrickirc.HattrickIrc; import org.hattrick.hattrickirc.config.BotConfig; import org.hattrick.hattrickirc.config.IrcConfig; +import org.hattrick.hattrickirc.data.Event; import org.hattrick.hattrickirc.data.Match; import org.jibble.pircbot.PircBot; @@ -68,6 +70,8 @@ } joinChannel(ircConfig.getChannel()); + + operators.addAll(botConfig.getOperators()); } public Messenger getMessenger() { @@ -75,93 +79,177 @@ } protected void onMessage(String channel, String sender, String login, String hostname, String message) { - - // everybody is allowed to perform these commands - // about - if(message.startsWith(botConfig.getPrefix() + "about")) { - sendMessage(ircConfig.getChannel(), "HattrickIRC Copyright (C) 2005 - Mathias Sulser <su...@su...>"); - sendMessage(ircConfig.getChannel(), "This application uses information from the online game service Hattrick.org." + - " This use has been approved by the developers and copyright owners of Hattrick.org, Extralives AB"); - } - - // only the owner and operators are allowed to perform these commands - if(sender.equalsIgnoreCase(botConfig.getOwner()) || operators.contains(sender)) { - // adds a match - if(message.startsWith(botConfig.getPrefix() + "add")) { - int matchId; + if (message.startsWith(botConfig.getPrefix())) { + String commandString = message.substring(botConfig.getPrefix().length()); + String[] commands = commandString.split(" "); + if (commands.length > 0) { try { - matchId = getMatchId(message); - Match match = HattrickIrc.getInstance().getMatchManager().addMatch(matchId); - logger.info("Match added: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); + Method method = this.getClass().getDeclaredMethod(commands[0], new Class[] {String.class, String[].class}); + String[] args = new String[commands.length - 1]; + for (int i = 1; i < commands.length; i++) { + args[i-1] = commands[i]; + } + method.invoke(this, new Object[] {sender, args}); } catch (Exception e) { - logger.error("couldn't add match: ", e); + return; } } - - // deletes a match - if(message.startsWith(botConfig.getPrefix() + "del")) { - int matchId; - try { - matchId = getMatchId(message); - Match match = HattrickIrc.getInstance().getMatchManager().removeMatch(matchId); - logger.info("Match removed: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); - } catch (Exception e) { - logger.error("couldn't remove match: ", e); + } + } + + protected void about(String sender, String[] args) { + sendMessage(ircConfig.getChannel(), "HattrickIRC Copyright (C) 2005 - Mathias Sulser <su...@su...>"); + sendMessage(ircConfig.getChannel(), "This application uses information from the online game service Hattrick.org." + + " This use has been approved by the developers and copyright owners of Hattrick.org, Extralives AB"); + } + + protected void add(String sender, String[] args) { + if (args.length > 0 && isOperator(sender)) { + try { + Match match = HattrickIrc.getInstance().getMatchManager().addMatch(args[0]); + if (match != null) { + logger.info("Match added: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); + info(sender, new String[] {args[0]}); + } else { + sendMessage(ircConfig.getChannel(), "Invalid match ID: " + args[0]); + logger.warn("Invalid match ID: " + args[0]); } + } catch (Exception e) { + logger.error("Couldn't add match: ", e); } - - // info - if(message.startsWith(botConfig.getPrefix() + "info")) { + } + } + + protected void del(String sender, String[] args) { + if (args.length > 0 && isOperator(sender)) { + try { + Match match = HattrickIrc.getInstance().getMatchManager().removeMatch(args[0]); + logger.info("Match removed: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); + } catch (Exception e) { + logger.error("couldn't remove match: ", e); + } + } + } + + protected void info(String sender, String[] args) { + if (isOperator(sender)) { + if (args.length > 0) { + Match currentMatch = HattrickIrc.getInstance().getMatchManager().getMatch(args[0]); + StringBuffer msgText = new StringBuffer(); + msgText.append(currentMatch.getMinute()); + msgText.append("': "); + msgText.append(currentMatch.getHomeTeam().getTeamName()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayTeam().getTeamName()); + msgText.append(" "); + msgText.append(currentMatch.getHomeGoals()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayGoals()); + + sendMessage(ircConfig.getChannel(), msgText.toString()); + } else { Collection matchColl = HattrickIrc.getInstance().getMatchManager().getMatches().values(); for(Iterator iter = matchColl.iterator(); iter.hasNext(); ) { Match currentMatch = (Match) iter.next(); - sendMessage(ircConfig.getChannel(), currentMatch.getHomeTeam().getTeamName() + - " - " + currentMatch.getAwayTeam().getTeamName() + - " " + currentMatch.getHomeGoals() + - " - " + currentMatch.getAwayGoals()); - } + StringBuffer msgText = new StringBuffer(); + msgText.append(currentMatch.getMinute()); + msgText.append("': "); + msgText.append(currentMatch.getHomeTeam().getTeamName()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayTeam().getTeamName()); + msgText.append(" "); + msgText.append(currentMatch.getHomeGoals()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayGoals()); + + sendMessage(ircConfig.getChannel(), msgText.toString()); + } } } - - // only the owner is allowed to perform these commands - if(sender.equalsIgnoreCase(botConfig.getOwner())) { - // exit - if(message.startsWith(botConfig.getPrefix() + "exit")) { - HattrickIrc.getInstance().getConnection().logout(); - } - - // operatoradd - if(message.startsWith(botConfig.getPrefix() + "operatoradd") && sender.equalsIgnoreCase(botConfig.getOwner())) { - operators.add(getNickName("operatoradd", message)); - logger.info("operator added: " + getNickName("operatoradd", message)); + } + + protected void allinfo(String sender, String[] args) { + if (isOperator(sender)) { + Collection matchColl = HattrickIrc.getInstance().getMatchManager().getMatches().values(); + for(Iterator iter = matchColl.iterator(); iter.hasNext(); ) { + Match currentMatch = (Match) iter.next(); + StringBuffer msgText = new StringBuffer(); + msgText.append("[").append(currentMatch.getMatchId()).append("] "); + msgText.append(currentMatch.getMinute()); + msgText.append("': "); + msgText.append(currentMatch.getHomeTeam().getTeamName()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayTeam().getTeamName()); + msgText.append(" "); + msgText.append(currentMatch.getHomeGoals()); + msgText.append(" - "); + msgText.append(currentMatch.getAwayGoals()); + msgText.append(" (Events: "); + msgText.append(currentMatch.getEvents().size()); + msgText.append(")"); + + sendMessage(ircConfig.getChannel(), msgText.toString()); } - - // operatordel - if(message.startsWith(botConfig.getPrefix() + "operatordel") && sender.equalsIgnoreCase(botConfig.getOwner())) { - operators.remove(getNickName("operatordel", message)); - logger.info("operator removed: " + getNickName("operatordel", message)); + } + } + + protected void report(String sender, String[] args) { + if (args.length > 0 && isOperator(sender)) { + Match currentMatch = HattrickIrc.getInstance().getMatchManager().getMatch(args[0]); + for(Iterator iter = currentMatch.getEvents().iterator(); iter.hasNext(); ) { + Event event = (Event) iter.next(); + sendMessage(ircConfig.getChannel(), event.getEventText(currentMatch)); } - - // botaccess - if(message.startsWith(botConfig.getPrefix() + "botaccess") && sender.equalsIgnoreCase(botConfig.getOwner())) { - StringBuffer buffer = new StringBuffer(); - for(Iterator iter = operators.iterator(); iter.hasNext(); ) { - buffer.append(iter.next() + " "); + } + } + + protected void exit(String sender, String[] args) { + if (isOwner(sender)) { + HattrickIrc.getInstance().getConnection().logout(); + } + } + + protected void operatoradd(String sender, String[] args) { + if (args.length > 0 && isOwner(sender)) { + operators.add(args[0]); + logger.info("operator added: " + args[0]); + } + } + + protected void operatordel(String sender, String[] args) { + if (args.length > 0 && isOwner(sender)) { + operators.remove(args[0]); + logger.info("operator removed: " + args[0]); + } + } + + protected void botaccess(String sender, String[] args) { + if (isOwner(sender)) { + sendMessage(getIrcConfig().getChannel(), "Owner: " + botConfig.getOwner()); + StringBuffer buffer = new StringBuffer(); + for(Iterator iter = operators.iterator(); iter.hasNext(); ) { + buffer.append(iter.next()); + if (iter.hasNext()) { + buffer.append(", "); } - sendMessage(ircConfig.getChannel(), "Owner: " + botConfig.getOwner() + " Operators: " + buffer.toString()); } + sendMessage(getIrcConfig().getChannel(), "Operators: " + buffer.toString()); } } - - private int getMatchId(String msg) throws Exception { - msg = msg.substring(botConfig.getPrefix().length() + 4); - if(msg.length() != 8) { - throw new Exception("incorrect matchid: " + msg); - } - return Integer.parseInt(msg); + + protected final boolean isOwner(String sender) { + return sender.equalsIgnoreCase(botConfig.getOwner()); } - private String getNickName(String cmd, String msg) { - return msg.substring(botConfig.getPrefix().length() + cmd.length() + 1); + protected final boolean isOperator(String sender) { + return (isOwner(sender) || operators.contains(sender)); + } + + public IrcConfig getIrcConfig() { + return this.ircConfig; + } + + public BotConfig getBotConfig() { + return this.botConfig; } } Index: Messenger.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/Messenger.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Messenger.java 8 Jul 2005 12:44:09 -0000 1.5 +++ Messenger.java 1 Oct 2006 17:41:07 -0000 1.6 @@ -24,12 +24,6 @@ */ package org.hattrick.hattrickirc.bot; -import java.util.Iterator; -import java.util.Map; - -import org.hattrick.hattrickirc.HattrickIrc; -import org.hattrick.hattrickirc.config.BotConfig; -import org.hattrick.hattrickirc.config.IrcConfig; import org.hattrick.hattrickirc.data.Event; import org.hattrick.hattrickirc.data.Match; @@ -41,16 +35,14 @@ private HattrickBot bot; private boolean output = false; - private IrcConfig ircConfig = HattrickIrc.getInstance().getConfig().getIrcConfig(); - private BotConfig botConfig = HattrickIrc.getInstance().getConfig().getBotConfig(); public Messenger(HattrickBot bot) { this.bot = bot; } - public void send(Event event) { + public void send(Match match, Event event) { if(output && EventFilter.isAllowed(event)) { - bot.sendMessage(ircConfig.getChannel(), event.getEventText()); + bot.sendMessage(bot.getIrcConfig().getChannel(), event.getEventText(match)); } } @@ -58,23 +50,4 @@ this.output = output; } - /** - * @param registeredMatches - */ - public void newTopic(Map registeredMatches) { - // set a new topic if the option is enabled and at least one - // match is added to the list - if(botConfig.isChangeTopic() && !registeredMatches.isEmpty()) { - StringBuffer topic = new StringBuffer(); - for(Iterator iter = registeredMatches.values().iterator(); iter.hasNext(); ) { - Match currentMatch = (Match) iter.next(); - topic.append(currentMatch.getHomeTeam().getTeamName() + " " - + currentMatch.getHomeGoals() + " : " - + currentMatch.getAwayGoals() + " " - + currentMatch.getAwayTeam().getTeamName() + " " - ); - } - bot.setTopic(ircConfig.getChannel(), topic.toString()); - } - } } |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:14
|
Update of /cvsroot/hattrickirc/HattrickIRC/lib In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/lib Added Files: junit-4.1.jar Log Message: Changes from Boy van der Werf (nethyperon) --- NEW FILE: junit-4.1.jar --- (This appears to be a binary file; contents omitted.) |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:14
|
Update of /cvsroot/hattrickirc/HattrickIRC/config In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/config Modified Files: config.xml Log Message: Changes from Boy van der Werf (nethyperon) Index: config.xml =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/config/config.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- config.xml 8 Jul 2005 12:47:09 -0000 1.9 +++ config.xml 1 Oct 2006 17:41:07 -0000 1.10 @@ -27,13 +27,12 @@ <!-- Specific bot configuration --> <BotConfig> - <Owner></Owner> <Prefix></Prefix> - - <!-- - true or false - --> - <ChangeTopic></ChangeTopic> + <Owner></Owner> + <Operators> + <!-- You can add as many BOT operators as you like --> + <operator></operator> + </Operators> <!-- none: shows nothing (only makes sense with changetopic=true) |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:11
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/data Modified Files: Match.java MatchManager.java Event.java Log Message: Changes from Boy van der Werf (nethyperon) Index: Event.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/Event.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Event.java 5 Feb 2005 16:46:29 -0000 1.1 +++ Event.java 1 Oct 2006 17:41:07 -0000 1.2 @@ -72,6 +72,15 @@ int getObjectPlayerId(); /** + * Object that, for goals and chances, is indicating the attacking team. + * For other event, this field usually indicates the team that is doing + * something. It may indicate other things for other events. + * + * @return the subject teamId + */ + int getSubjectTeamId(); + + /** * A hattrick <code>EventKey</code> is constructed with a major and * minor number. Example: * <pre><EventKey>510_2</EventKey></pre> @@ -94,14 +103,6 @@ * * @return event text */ - String getEventText(); + String getEventText(Match match); - /** - * Object that, for goals and chances, is indicating the attacking team. - * For other event, this field usually indicates the team that is doing - * something. It may indicate other things for other events. - * - * @return the subject team - */ - Team getSubjectTeam(); } Index: Match.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/Match.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Match.java 6 Feb 2005 21:19:31 -0000 1.2 +++ Match.java 1 Oct 2006 17:41:07 -0000 1.3 @@ -80,6 +80,13 @@ */ int getHomeGoals(); + /** + * The current number of minutes a match is in. + * + * @return Match time + */ + int getMinute(); + /** * Returns the container for all events. * Index: MatchManager.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/MatchManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MatchManager.java 5 Feb 2005 16:46:30 -0000 1.1 +++ MatchManager.java 1 Oct 2006 17:41:07 -0000 1.2 @@ -25,6 +25,7 @@ package org.hattrick.hattrickirc.data; +import java.util.Date; import java.util.Map; @@ -40,7 +41,7 @@ * @param matchId * @return The added match */ - Match addMatch(int matchId); + Match addMatch(String matchId) throws Exception; /** * Removes a match @@ -48,7 +49,15 @@ * @param matchId * @return The deleted match */ - Match removeMatch(int matchId); + Match removeMatch(String matchId) throws Exception; + + /** + * Returns a registered a match + * + * @param matchId + * @return The registered match + */ + Match getMatch(String matchId); /** * Returns all registered matches @@ -57,4 +66,6 @@ */ Map getMatches(); + Date getRefreshDate(); + } |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:11
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/impl In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/config/impl Modified Files: BotConfigImpl.java Log Message: Changes from Boy van der Werf (nethyperon) Index: BotConfigImpl.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/impl/BotConfigImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- BotConfigImpl.java 2 Jul 2005 14:13:02 -0000 1.4 +++ BotConfigImpl.java 1 Oct 2006 17:41:07 -0000 1.5 @@ -25,6 +25,10 @@ package org.hattrick.hattrickirc.config.impl; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import org.hattrick.hattrickirc.bot.EventFilter; import org.hattrick.hattrickirc.config.BotConfig; import org.jdom.Element; @@ -39,14 +43,11 @@ private boolean changeTopic = false; private int eventFilter; private String prefix = ""; + private List operators = null; public BotConfigImpl(Element node) { owner = node.getChildText("Owner"); - if(node.getChildText("ChangeTopic").equalsIgnoreCase("true")) { - changeTopic = true; - } - prefix = node.getChildText("Prefix"); if(node.getChildText("EventFilter").equalsIgnoreCase("none")) { @@ -58,15 +59,17 @@ if(node.getChildText("EventFilter").equalsIgnoreCase("all")) { eventFilter = EventFilter.ALL; } + List childList = node.getChild("Operators").getChildren(); + if(childList != null) { + operators = new ArrayList(); + for(Iterator iter = childList.iterator(); iter.hasNext(); ) { + Element currentElement = (Element) iter.next(); + operators.add(currentElement.getText()); + } + } } /** - * @return Returns the changeTopic. - */ - public boolean isChangeTopic() { - return changeTopic; - } - /** * @return Returns the eventFilter. */ public int getEventFilter() { @@ -78,6 +81,13 @@ public String getOwner() { return owner; } + + /** + * @return Returns the operators. + */ + public List getOperators() { + return operators; + } public String toString() { return "[ owner=" + owner + |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:11
|
Update of /cvsroot/hattrickirc/HattrickIRC In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808 Modified Files: build.xml Added Files: .cvsignore Log Message: Changes from Boy van der Werf (nethyperon) --- NEW FILE: .cvsignore --- HattrickIRC.scrapbook.jpage .project .classpath Index: build.xml =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/build.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- build.xml 5 Jul 2005 12:53:40 -0000 1.12 +++ build.xml 1 Oct 2006 17:41:07 -0000 1.13 @@ -10,8 +10,8 @@ <property name="name" value="hattrickirc" /> <property name="Name" value="HattrickIrc" /> - <property name=".version" value="2.0.0-alpha" /> - <property name="_version" value="2_0_0-alpha" /> + <property name=".version" value="2.0.0-alpha-R2" /> + <property name="_version" value="2_0_0-alpha-R2" /> <property name="src.dir" value="src" /> <property name="lib.dir" value="lib" /> @@ -87,17 +87,18 @@ <!-- =================================================================== --> <target name="test.run" depends="test.compile" description="Runs the test code"> <mkdir dir="${test.reports.dir}"/> - <junit printsummary="yes" fork="yes"> - <classpath> - <pathelement location="${build.classes}" /> - <path refid="base.classpath" /> - </classpath> - <formatter type="plain" /> - <batchtest fork="yes" todir="${test.reports.dir}"> - <fileset dir="${test.src.dir}"> - <include name="**/*Test.java" /> - </fileset> - </batchtest> + + <junit printsummary="yes" fork="yes"> + <classpath> + <pathelement location="${build.classes}" /> + <path refid="base.classpath" /> + </classpath> + <formatter type="plain" /> + <batchtest fork="yes" todir="${test.reports.dir}"> + <fileset dir="${test.src.dir}"> + <include name="**/*Test.java" /> + </fileset> + </batchtest> </junit> </target> |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:11
|
Update of /cvsroot/hattrickirc/HattrickIRC/test/org/hattrick/hattrickirc/data/impl In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/test/org/hattrick/hattrickirc/data/impl Modified Files: EventImplTest.java Log Message: Changes from Boy van der Werf (nethyperon) Index: EventImplTest.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/test/org/hattrick/hattrickirc/data/impl/EventImplTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- EventImplTest.java 9 Feb 2005 07:11:52 -0000 1.3 +++ EventImplTest.java 1 Oct 2006 17:41:07 -0000 1.4 @@ -77,7 +77,7 @@ } public void testGetEventText() { - assertEquals(event.getEventText(), "BVB09 made a bid to take the lead as a ball coming in from the right hand side left Ivo Seidner completely alone with keeper Alfonso Ramos, who made a spectacular block."); + assertEquals(event.getEventText(null), "BVB09 made a bid to take the lead as a ball coming in from the right hand side left Ivo Seidner completely alone with keeper Alfonso Ramos, who made a spectacular block."); } public void testGetSubjectTeam() { |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:11
|
Update of /cvsroot/hattrickirc/HattrickIRC/test/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/test/org/hattrick/hattrickirc/bot Added Files: HattrickBotTest.java Log Message: Changes from Boy van der Werf (nethyperon) --- NEW FILE: HattrickBotTest.java --- /* * HattrickIRC * * Copyright (c) 2005 * * Mathias Sulser <su...@su...> * * 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. * * * $Id: HattrickBotTest.java,v 1.1 2006/10/01 17:41:07 suls Exp $ */ package org.hattrick.hattrickirc.bot; import junit.framework.TestCase; /** * @version $Id: HattrickBotTest.java,v 1.1 2006/10/01 17:41:07 suls Exp $ * @author $Author: suls $ */ public class HattrickBotTest extends TestCase { HattrickBot bot = null; /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); bot = new HattrickBot(); } public void testGetMatchId() { // assertEquals(bot.getMatchId("!!!add 12345"), 12345); } } |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/config Modified Files: BotConfig.java Log Message: Changes from Boy van der Werf (nethyperon) Index: BotConfig.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/BotConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- BotConfig.java 2 Jul 2005 14:13:01 -0000 1.5 +++ BotConfig.java 1 Oct 2006 17:41:07 -0000 1.6 @@ -24,15 +24,13 @@ */ package org.hattrick.hattrickirc.config; +import java.util.List; + /** * @version $Id$ * @author $Author$ */ public interface BotConfig { - /** - * @return Returns the changeTopic. - */ - public boolean isChangeTopic(); /** * @return Returns the eventFilter. @@ -45,6 +43,11 @@ public String getOwner(); /** + * @return Returns the performCommands. + */ + public abstract List getOperators(); + + /** * @return Returns the owner. */ public String getPrefix(); |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/impl In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20808/src/org/hattrick/hattrickirc/data/impl Modified Files: MatchManagerImpl.java EventImpl.java MatchImpl.java Log Message: Changes from Boy van der Werf (nethyperon) Index: MatchImpl.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/impl/MatchImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- MatchImpl.java 29 Jun 2005 13:09:57 -0000 1.5 +++ MatchImpl.java 1 Oct 2006 17:41:07 -0000 1.6 @@ -24,6 +24,8 @@ */ package org.hattrick.hattrickirc.data.impl; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; @@ -42,8 +44,10 @@ */ public class MatchImpl implements Match { + private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private int matchId = 0; - private Date matchDate = new Date(); + private Date matchDate = null; private Team homeTeam = null; private Team awayTeam = null; private List events = new LinkedList(); @@ -52,6 +56,12 @@ private Logger logger = Logger.getLogger(MatchImpl.class); public MatchImpl(Element data) { + this.matchId = Integer.parseInt(data.getChildText("MatchID")); + try { + this.matchDate = formatter.parse(data.getChildText("MatchDate")); + } catch (ParseException e) { + this.matchDate = null; + } refresh(data); logger.debug("Match added: " + matchId); } @@ -105,6 +115,24 @@ return homeGoals; } + public int getMinute() { + int minute = (int) ((HattrickIrc.getInstance().getMatchManager().getRefreshDate().getTime() - this.matchDate.getTime()) / (60 * 1000)); + if (minute < 0) { + return 0; + } else if (minute > 45) { + minute -= 15; + if (minute < 45) { + return 45; + } else if (minute > 90) { + return 90; + } else { + return minute; + } + } else { + return minute; + } + } + /** * Checks if a event is already registered. * @@ -125,10 +153,6 @@ * @see org.hattrick.hattrickirc.data.Refreshable#refresh(org.jdom.Element) */ public void refresh(Element data) { - matchId = Integer.parseInt(data.getChildText("MatchID")); - // TODO: use the match date .. - //matchDate = data.getChildText("MatchDate"); - if(homeTeam == null) homeTeam = new TeamImpl(data.getChild("HomeTeam")); if(awayTeam == null) awayTeam = new TeamImpl(data.getChild("AwayTeam")); @@ -143,7 +167,7 @@ if(!isInEventList(currentEvent)) { events.add(currentEvent); - HattrickIrc.getInstance().getBot().getMessenger().send(currentEvent); + HattrickIrc.getInstance().getBot().getMessenger().send(this, currentEvent); } } Index: MatchManagerImpl.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/impl/MatchManagerImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MatchManagerImpl.java 8 Jul 2005 12:44:08 -0000 1.6 +++ MatchManagerImpl.java 1 Oct 2006 17:41:07 -0000 1.7 @@ -24,6 +24,8 @@ */ package org.hattrick.hattrickirc.data.impl; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -44,7 +46,9 @@ */ public class MatchManagerImpl implements MatchManager { + private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private Map registeredMatches = new HashMap(10); + private Date refreshDate; private Logger logger = Logger.getLogger(MatchManagerImpl.class); @@ -53,12 +57,13 @@ timer.schedule (new TimerTask () { public void run () { logger.debug("refreshing data .."); - Element data = HattrickIrc.getInstance().getConnection().performCommand(ActionCommands.LIVE_VIEW_NEW); - - HattrickIrc.getInstance().getMatchManager().refresh(data); - - HattrickIrc.getInstance().getBot().getMessenger().newTopic(registeredMatches); - logger.debug(".. refreshing finished"); + try { + Element data = HattrickIrc.getInstance().getConnection().performCommand(ActionCommands.LIVE_VIEW_NEW); + HattrickIrc.getInstance().getMatchManager().refresh(data); + logger.debug(".. refreshing finished"); + } catch (Exception e) { + logger.error(".. refreshing failed: " + e.getMessage()); + } } }, 10000, @@ -69,54 +74,56 @@ refresh(data); } - /* (non-Javadoc) - * @see org.hattrick.ihtirc.data.MatchManager#addMatch(int) - */ - public Match addMatch(int matchId) { + public Match addMatch(String matchId) throws Exception { refresh(HattrickIrc.getInstance().getConnection().performCommand(ActionCommands.LIVE_ADD_MATCH + matchId)); - return (Match) registeredMatches.get(String.valueOf(matchId)); + return (Match) registeredMatches.get(matchId); } - /* (non-Javadoc) - * @see org.hattrick.ihtirc.data.MatchManager#removeMatch(int) - */ - public Match removeMatch(int matchId) { - Match removedMatch = (Match) registeredMatches.remove(String.valueOf(matchId)); + public Match removeMatch(String matchId) throws Exception { + Match removedMatch = (Match) registeredMatches.remove(matchId); refresh(HattrickIrc.getInstance().getConnection().performCommand(ActionCommands.LIVE_DELETE_MATCH + removedMatch.getMatchId())); return removedMatch; } - /* (non-Javadoc) - * @see org.hattrick.ihtirc.data.MatchManager#getMatches() - */ + public Match getMatch(String matchId) { + return (Match) registeredMatches.get(matchId); + } + public Map getMatches() { return registeredMatches; } + public Date getRefreshDate() { + return this.refreshDate; + } + /* (non-Javadoc) * @see org.hattrick.ihtirc.data.MatchManager#update() */ public synchronized void refresh(Element data) { - List newMatches = data.getChild("MatchList").getChildren("Match"); - for(Iterator matchIter = newMatches.iterator(); matchIter.hasNext(); ) { - Element currentMatchNode = (Element) matchIter.next(); - String currentMatchId = currentMatchNode.getChildText("MatchID"); - - // tests whether the match exists and has to be updated - // or it's a new one .. - if(registeredMatches.containsKey(currentMatchId)) { - HattrickIrc.getInstance().getBot().getMessenger().setOutput(true); - Match currentMatch = (Match) registeredMatches.get(currentMatchId); - currentMatch.refresh(currentMatchNode); - logger.debug("already registered .. updating match id=" + currentMatch.getMatchId()); - } else { - logger.debug("adding new match"); - HattrickIrc.getInstance().getBot().getMessenger().setOutput(false); - Match newMatch = new MatchImpl(currentMatchNode); - registeredMatches.put(String.valueOf(newMatch.getMatchId()), newMatch); + try { + this.refreshDate = formatter.parse(data.getChildText("FetchedDate")); + List newMatches = data.getChild("MatchList").getChildren("Match"); + for(Iterator matchIter = newMatches.iterator(); matchIter.hasNext(); ) { + Element currentMatchNode = (Element) matchIter.next(); + String currentMatchId = currentMatchNode.getChildText("MatchID"); + + // tests whether the match exists and has to be updated + // or it's a new one .. + if(registeredMatches.containsKey(currentMatchId)) { + HattrickIrc.getInstance().getBot().getMessenger().setOutput(true); + Match currentMatch = (Match) registeredMatches.get(currentMatchId); + currentMatch.refresh(currentMatchNode); + logger.debug("already registered .. updating match id=" + currentMatch.getMatchId()); + } else { + logger.debug("adding new match"); + HattrickIrc.getInstance().getBot().getMessenger().setOutput(false); + Match newMatch = new MatchImpl(currentMatchNode); + registeredMatches.put(String.valueOf(newMatch.getMatchId()), newMatch); + } } + } catch (Exception e) { } - // set the topic after adding a new match - HattrickIrc.getInstance().getBot().getMessenger().newTopic(registeredMatches); } + } \ No newline at end of file Index: EventImpl.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/data/impl/EventImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- EventImpl.java 2 Jul 2005 14:13:00 -0000 1.4 +++ EventImpl.java 1 Oct 2006 17:41:07 -0000 1.5 @@ -28,7 +28,7 @@ import java.util.StringTokenizer; import org.hattrick.hattrickirc.data.Event; -import org.hattrick.hattrickirc.data.Team; +import org.hattrick.hattrickirc.data.Match; import org.jdom.Element; /** @@ -36,8 +36,10 @@ * @author $Author$ */ public class EventImpl implements Event { - private int minute = 0; + + private int minute = 0; private int index = 0; + private int subjectTeamId = 0; private int subjectPlayerId = 0; private int objectPlayerId = 0; private int eventKeyMajor = 0; @@ -46,10 +48,10 @@ public EventImpl(Element eventData) { - // missing team index = Integer.parseInt(eventData.getAttributeValue("Index")); + minute = Integer.parseInt(eventData.getChildText("Minute")); subjectPlayerId = Integer.parseInt(eventData.getChildText("SubjectPlayerID")); - minute = Integer.parseInt(eventData.getChildText("SubjectTeamID")); + subjectTeamId = Integer.parseInt(eventData.getChildText("SubjectTeamID")); objectPlayerId = Integer.parseInt(eventData.getChildText("ObjectPlayerID")); String[] eventKeys = eventData.getChildText("EventKey").split("_"); @@ -87,6 +89,10 @@ return objectPlayerId; } + public int getSubjectTeamId() { + return subjectTeamId; + } + /* (non-Javadoc) * @see org.hattrick.hattrickirc.data.Event#getEventKeyMajor() */ @@ -104,7 +110,7 @@ /* (non-Javadoc) * @see org.hattrick.hattrickirc.data.Event#getEventText() */ - public String getEventText() { + public String getEventText(Match match) { String ret = eventText.replaceAll("<.*?>", ""); ret = ret.replaceAll("&.*?;", ""); @@ -116,15 +122,25 @@ if (st.hasMoreTokens()) textWithoutDoubleWhitespaces.append(" "); } - return textWithoutDoubleWhitespaces.toString(); - } + + StringBuffer msgText = new StringBuffer(); + msgText.append(this.minute); + msgText.append("' "); + if (match != null) { + if (subjectTeamId == match.getHomeTeam().getTeamId()) { + msgText.append(match.getHomeTeam().getTeamName()); + } else if (subjectTeamId == match.getAwayTeam().getTeamId()) { + msgText.append(match.getAwayTeam().getTeamName()); + } else { + msgText.append(match.getHomeTeam().getTeamName()); + msgText.append(" - "); + msgText.append(match.getAwayTeam().getTeamName()); + } + } + msgText.append(" : "); + msgText.append(textWithoutDoubleWhitespaces); - /* (non-Javadoc) - * @see org.hattrick.hattrickirc.data.Event#getSubjectTeam() - */ - public Team getSubjectTeam() { - // TODO: implement getSubjectTeam() - return null; + return msgText.toString(); } } |
From: Mathias S. <su...@us...> - 2006-10-01 17:41:02
|
Update of /cvsroot/hattrickirc/HattrickIRC/test/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20786/test/org/hattrick/hattrickirc/bot Log Message: Directory /cvsroot/hattrickirc/HattrickIRC/test/org/hattrick/hattrickirc/bot added to the repository |
From: Mathias S. <su...@us...> - 2005-07-05 12:53:49
|
Update of /cvsroot/hattrickirc/HattrickIRC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5592 Modified Files: build.xml Log Message: Index: build.xml =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/build.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- build.xml 2 Jul 2005 14:13:02 -0000 1.11 +++ build.xml 5 Jul 2005 12:53:40 -0000 1.12 @@ -153,6 +153,8 @@ </copy> <copy file="${config.dir}/config.xml" todir="${dist.current.dir}/config"/> <copy file="${doc.dir}/Readme.txt" todir="${dist.current.dir}"/> + <copy file="${doc.dir}/Config-Readme.txt" todir="${dist.current.dir}"/> + <copy file="${doc.dir}/Todo.txt" todir="${dist.current.dir}"/> <copy file="license.txt" todir="${dist.current.dir}"/> </target> |
From: Mathias S. <su...@us...> - 2005-07-05 12:53:49
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5592/src/org/hattrick/hattrickirc/bot Modified Files: Messenger.java EventFilter.java Log Message: Index: EventFilter.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/EventFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- EventFilter.java 2 Jul 2005 14:13:02 -0000 1.2 +++ EventFilter.java 5 Jul 2005 12:53:41 -0000 1.3 @@ -24,6 +24,9 @@ */ package org.hattrick.hattrickirc.bot; +import org.hattrick.hattrickirc.HattrickIrc; +import org.hattrick.hattrickirc.data.Event; + /** * @version $Id$ * @author $Author$ @@ -44,4 +47,21 @@ * shows everything */ public static final int ALL = 2; + + public static boolean isAllowed(Event event) { + if(HattrickIrc.getInstance().getConfig().getBotConfig().getEventFilter() == EventFilter.NONE) { + return false; + } + + // TODO: implement GOALS filter + if(HattrickIrc.getInstance().getConfig().getBotConfig().getEventFilter() == EventFilter.GOALS) { + return false; + } + + if(HattrickIrc.getInstance().getConfig().getBotConfig().getEventFilter() == EventFilter.ALL) { + return true; + } + + return false; + } } Index: Messenger.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/Messenger.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Messenger.java 2 Jul 2005 14:13:02 -0000 1.3 +++ Messenger.java 5 Jul 2005 12:53:40 -0000 1.4 @@ -49,7 +49,7 @@ } public void send(Event event) { - if(output && isAllowed(event)) { + if(output && EventFilter.isAllowed(event)) { bot.sendMessage(ircConfig.getChannel(), event.getEventText()); } } @@ -58,23 +58,6 @@ this.output = output; } - public boolean isAllowed(Event event) { - if(botConfig.getEventFilter() == EventFilter.NONE) { - return false; - } - - // TODO: implement GOALS filter - if(botConfig.getEventFilter() == EventFilter.GOALS) { - return false; - } - - if(botConfig.getEventFilter() == EventFilter.ALL) { - return true; - } - - return false; - } - /** * @param registeredMatches */ |
From: Mathias S. <su...@us...> - 2005-07-05 12:53:49
|
Update of /cvsroot/hattrickirc/HattrickIRC/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5592/doc Added Files: Config-Readme.txt Log Message: --- NEW FILE: Config-Readme.txt --- ************************************************************ Welcome to the "HattrickIRC 2.0.0-alpha" CONFIG-README FILE! ************************************************************ July 4, 2005 $Id: Config-Readme.txt,v 1.1 2005/07/05 12:53:40 suls Exp $ To setup the bot correctly it is needed to fill the configuration file with the proper values. This readme provides a short overview and describes each node in the config. I - IRC-CONFIG II - HATTRICK-CONFIG III - BOT-CONFIG IV - NOTES I - IRC-CONFIG ----------------------- Network: hostname of the irc server (irc.freenode.org) Port: connection port (6667) Channel: channel the bot should join (#hattrickirc) BotName: the bot's nickname (HattrickIrcTest) PerformCommands: if the bot should perform any commands add for each of them a <command> line (<command>MSG suls hi, boss</command>) II - HATTRICK-CONFIG ----------------------- LoginName: your loginname on hattrick.org (DerSuls) SecurityCode: your securitiycode and NOT password! III - BOT-CONFIG ----------------------- Owner: your irc nick (suls) Prefix: your prefix for each command (!) NOTE: if ! is the prefix your bot will react on !add !exit etc. ChangeTopic: sets the current standing as topic (true) EventFilter: filters the written events (all) EventView: not yet implemented IV - NOTES ----------------------- This is only a temporary documentation. If you still have question use the hattrick conference or the mailinglist. |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:12
|
Update of /cvsroot/hattrickirc/HattrickIRC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865 Modified Files: build.xml Log Message: Index: build.xml =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/build.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- build.xml 29 Jun 2005 13:09:56 -0000 1.10 +++ build.xml 2 Jul 2005 14:13:02 -0000 1.11 @@ -168,12 +168,12 @@ <include name="${src.dir}/**/*" /> <include name="${doc.dir}/**/*" /> <include name="${bin.dir}/**/*" /> - <include name="${config.dir}/**/*" /> <include name="${test.src.dir}/**/*" /> <include name="build.xml" /> <include name="license.txt" /> </fileset> </copy> + <copy file="${config.dir}/config.xml" todir="${dist.dev.dir}/config"/> </target> <!-- =================================================================== --> |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:12
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/src/org/hattrick/hattrickirc/config/impl Modified Files: BotConfigImpl.java Log Message: Index: BotConfigImpl.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/impl/BotConfigImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- BotConfigImpl.java 28 Jun 2005 11:50:54 -0000 1.3 +++ BotConfigImpl.java 2 Jul 2005 14:13:02 -0000 1.4 @@ -25,6 +25,7 @@ package org.hattrick.hattrickirc.config.impl; +import org.hattrick.hattrickirc.bot.EventFilter; import org.hattrick.hattrickirc.config.BotConfig; import org.jdom.Element; @@ -36,14 +37,27 @@ private String owner = ""; private boolean changeTopic = false; - private String eventFilter = ""; - private String prefix; + private int eventFilter; + private String prefix = ""; public BotConfigImpl(Element node) { owner = node.getChildText("Owner"); - changeTopic = Boolean.getBoolean(node.getChildText("ChangeTopic")); - eventFilter = node.getChildText("EventFilter"); + + if(node.getChildText("ChangeTopic").equalsIgnoreCase("true")) { + changeTopic = true; + } + prefix = node.getChildText("Prefix"); + + if(node.getChildText("EventFilter").equalsIgnoreCase("none")) { + eventFilter = EventFilter.NONE; + } + if(node.getChildText("EventFilter").equalsIgnoreCase("goals")) { + eventFilter = EventFilter.GOALS; + } + if(node.getChildText("EventFilter").equalsIgnoreCase("all")) { + eventFilter = EventFilter.ALL; + } } /** @@ -55,7 +69,7 @@ /** * @return Returns the eventFilter. */ - public String getEventFilter() { + public int getEventFilter() { return eventFilter; } /** |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:12
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/src/org/hattrick/hattrickirc/bot Modified Files: EventFilter.java HattrickBot.java Messenger.java Log Message: Index: HattrickBot.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/HattrickBot.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- HattrickBot.java 29 Jun 2005 13:09:57 -0000 1.4 +++ HattrickBot.java 2 Jul 2005 14:13:02 -0000 1.5 @@ -66,12 +66,16 @@ joinChannel(ircConfig.getChannel()); } + + public Messenger getMessenger() { + return messenger; + } protected void onMessage(String channel, String sender, String login, String hostname, String message) { // about if(message.startsWith(botConfig.getPrefix() + "about")) { - sendMessage(getChannels()[0], "HattrickIRC Copyright (C) 2005 - Mathias Sulser <su...@su...>"); - sendMessage(getChannels()[0], "This application uses information from the online game service Hattrick.org." + + sendMessage(ircConfig.getChannel(), "HattrickIRC Copyright (C) 2005 - Mathias Sulser <su...@su...>"); + sendMessage(ircConfig.getChannel(), "This application uses information from the online game service Hattrick.org." + " This use has been approved by the developers and copyright owners of Hattrick.org, Extralives AB"); } @@ -95,7 +99,7 @@ try { matchId = getMatchId(message); Match match = HattrickIrc.getInstance().getMatchManager().removeMatch(matchId); - logger.info("Match added: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); + logger.info("Match removed: " + match.getHomeTeam().getTeamName() + " - " + match.getAwayTeam().getTeamName()); } catch (Exception e) { logger.error("couldn't remove match: ", e); } @@ -106,7 +110,7 @@ Collection matchColl = HattrickIrc.getInstance().getMatchManager().getMatches().values(); for(Iterator iter = matchColl.iterator(); iter.hasNext(); ) { Match currentMatch = (Match) iter.next(); - sendMessage(getChannels()[0], currentMatch.getHomeTeam().getTeamName() + + sendMessage(ircConfig.getChannel(), currentMatch.getHomeTeam().getTeamName() + " - " + currentMatch.getAwayTeam().getTeamName() + " " + currentMatch.getHomeGoals() + " - " + currentMatch.getAwayGoals()); @@ -115,12 +119,11 @@ // exit if(message.startsWith(botConfig.getPrefix() + "exit")) { - logger.info(".. exiting HattrickIrc"); - System.exit(0); + HattrickIrc.getInstance().getConnection().logout(); } } } - + private int getMatchId(String msg) throws Exception { msg = msg.substring(botConfig.getPrefix().length() + 4); if(msg.length() != 8) { @@ -128,7 +131,4 @@ } return Integer.parseInt(msg); } - public Messenger getMessenger() { - return messenger; - } } Index: EventFilter.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/EventFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- EventFilter.java 23 Jun 2005 12:29:41 -0000 1.1 +++ EventFilter.java 2 Jul 2005 14:13:02 -0000 1.2 @@ -29,5 +29,19 @@ * @author $Author$ */ public class EventFilter { - + + /** + * shows nothing (only makes sense with changetopic=true) + */ + public static final int NONE = 0; + + /** + * shows only the goals + */ + public static final int GOALS = 1; + + /** + * shows everything + */ + public static final int ALL = 2; } Index: Messenger.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/bot/Messenger.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Messenger.java 29 Jun 2005 13:09:57 -0000 1.2 +++ Messenger.java 2 Jul 2005 14:13:02 -0000 1.3 @@ -24,8 +24,14 @@ */ package org.hattrick.hattrickirc.bot; +import java.util.Iterator; +import java.util.Map; + import org.hattrick.hattrickirc.HattrickIrc; +import org.hattrick.hattrickirc.config.BotConfig; +import org.hattrick.hattrickirc.config.IrcConfig; import org.hattrick.hattrickirc.data.Event; +import org.hattrick.hattrickirc.data.Match; /** * @version $Id$ @@ -35,19 +41,55 @@ private HattrickBot bot; private boolean output = false; - + private IrcConfig ircConfig = HattrickIrc.getInstance().getConfig().getIrcConfig(); + private BotConfig botConfig = HattrickIrc.getInstance().getConfig().getBotConfig(); + public Messenger(HattrickBot bot) { this.bot = bot; } public void send(Event event) { - // TODO: check if the event is allowed to be send - if(output) { - bot.sendMessage(HattrickIrc.getInstance().getConfig().getIrcConfig().getChannel(), event.getEventText()); + if(output && isAllowed(event)) { + bot.sendMessage(ircConfig.getChannel(), event.getEventText()); } } public void setOutput(boolean output) { this.output = output; } + + public boolean isAllowed(Event event) { + if(botConfig.getEventFilter() == EventFilter.NONE) { + return false; + } + + // TODO: implement GOALS filter + if(botConfig.getEventFilter() == EventFilter.GOALS) { + return false; + } + + if(botConfig.getEventFilter() == EventFilter.ALL) { + return true; + } + + return false; + } + + /** + * @param registeredMatches + */ + public void newTopic(Map registeredMatches) { + if(botConfig.isChangeTopic()) { + StringBuffer topic = new StringBuffer(); + for(Iterator iter = registeredMatches.values().iterator(); iter.hasNext(); ) { + Match currentMatch = (Match) iter.next(); + topic.append(currentMatch.getHomeTeam().getTeamName() + " " + + currentMatch.getHomeGoals() + " : " + + currentMatch.getAwayGoals() + " " + + currentMatch.getAwayTeam().getTeamName() + " " + ); + } + bot.setTopic(ircConfig.getChannel(), topic.toString()); + } + } } |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/doc Modified Files: Readme.txt Added Files: Todo.txt Log Message: --- NEW FILE: Todo.txt --- *********************************************************** Welcome to the "HattrickIRC 2.0.0-alpha" TODO FILE! *********************************************************** July 01, 2005 $Id: Todo.txt,v 1.1 2005/07/02 14:13:02 suls Exp $ .. if you would like to have a new feature in the next release just post your detailed proposal on the project page! Index: Readme.txt =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/doc/Readme.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Readme.txt 29 Jun 2005 13:09:58 -0000 1.4 +++ Readme.txt 2 Jul 2005 14:13:01 -0000 1.5 @@ -13,14 +13,14 @@ .. sooner or later there will be a homepage ;) - I - SYSTEM REQUIREMENTS + I - REQUIREMENTS II - HOW TO START III - COMMANDS IV - SUPPORT V - KNOWN ISSUES VI - THANKS -I - SYSTEM REQUIREMENTS +I - REQUIREMENTS ----------------------- * Java installed @@ -39,6 +39,8 @@ 2b) Unix: - chmod the start.sh file 766 - run ./start.sh .. if you don't like to waste your console pipe it with ' > hattrickirc.log' into a file + +3) Have fun! III - COMMANDS -------------- @@ -68,6 +70,7 @@ * !add * !del * !info + * !exit IV - SUPPORT ------------ @@ -81,7 +84,9 @@ V - KNOWN ISSUES ---------------- - Because it's the first public release no bugs etc are known .. +Because it's the first public release no bugs etc are known .. + +Note: some fields in the configuration aren't implemented yet. VI - THANKS ----------- |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/src/org/hattrick/hattrickirc/net Modified Files: HattrickConnection.java Log Message: Index: HattrickConnection.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/net/HattrickConnection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- HattrickConnection.java 29 Jun 2005 13:09:57 -0000 1.8 +++ HattrickConnection.java 2 Jul 2005 14:13:00 -0000 1.9 @@ -67,8 +67,7 @@ logger.debug("connected to: " + hattrickServerURL); } catch(Exception e) { logger.error("couldn't establish any connection: ", e); - logger.info(".. exiting HattrickIrc"); - System.exit(0); + logout(); } } @@ -95,8 +94,7 @@ logger.info("sucsessfully logged in on hattrick.org!"); } else { logger.info("wrong username or password."); - logger.info(".. exiting HattrickIrc"); - System.exit(0); + logout(); } logger.info(".. login finished"); @@ -110,11 +108,18 @@ */ public void logout() { try { - URL login = new URL(hattrickServerURL + "/Common/default.asp?outputType=XML&actionType=logout&loginType=CHPP"); - HttpURLConnection huc = (HttpURLConnection) login.openConnection(); - huc.setRequestProperty("User-Agent", USER_AGENT); +// URL logout = new URL(hattrickServerURL + "/Common/default.asp?outputType=XML&actionType=logout&loginType=CHPP"); +// HttpURLConnection huc = (HttpURLConnection) logout.openConnection(); +// huc.setRequestProperty("User-Agent", USER_AGENT); + Element logoutData = performCommand("/Common/default.asp?outputType=XML&actionType=logout&loginType=CHPP"); + if(logoutData.getChildText("ActionSuccessful").equalsIgnoreCase("true")) { + logger.info("sucsessfully logged out .."); + } } catch(Exception e) { logger.error("couldn't logout: ", e); + } finally { + logger.info(".. exiting HattrickIrc"); + System.exit(0); } } |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/config Modified Files: config.xml Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- my-config.xml Index: config.xml =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/config/config.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- config.xml 29 Jun 2005 13:09:57 -0000 1.7 +++ config.xml 2 Jul 2005 14:13:01 -0000 1.8 @@ -29,20 +29,23 @@ <BotConfig> <Owner></Owner> <Prefix></Prefix> + <!-- true or false - - Note: doesn't work --> <ChangeTopic></ChangeTopic> + <!-- - goals: shows only the goals + none: shows nothing (only makes sense with changetopic=true) + goals: shows only the goals (not yet implemented!) all: shows everything - - Note: doesn't work --> <EventFilter></EventFilter> - + + <!-- + Note: note yet implemented + --> + <EventView></EventView> <!-- to be continued .. --> </BotConfig> </HattrickIRC> \ No newline at end of file |
From: Mathias S. <su...@us...> - 2005-07-02 14:13:10
|
Update of /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2865/src/org/hattrick/hattrickirc/config Modified Files: BotConfig.java Log Message: Index: BotConfig.java =================================================================== RCS file: /cvsroot/hattrickirc/HattrickIRC/src/org/hattrick/hattrickirc/config/BotConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- BotConfig.java 28 Jun 2005 11:50:53 -0000 1.4 +++ BotConfig.java 2 Jul 2005 14:13:01 -0000 1.5 @@ -37,7 +37,7 @@ /** * @return Returns the eventFilter. */ - public String getEventFilter(); + public int getEventFilter(); /** * @return Returns the owner. |