Skip to content

Commit

Permalink
added aG surf skill map announcing | 5.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed Jun 17, 2016
1 parent 58f5b06 commit c757a8d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#Changelog
---
####5.7.5
- Added map announcing for the aG Surf Skill server

####5.7.4
- Fixed YouTube stats' date (now removes everything infront of the first number, which should include many many languages)
- Fixed "No permissions" message getting sent to the user as a PM instead of a channel message
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bl4ckscor3.bot</groupId>
<artifactId>bl4ckb0t</artifactId>
<version>5.7.4</version>
<version>5.7.5</version>
<name>bl4ckb0t</name>
<description>An IRC bot designed and managed by bl4ckscor3</description>
<url>https://github.com/bl4ckscor3/bl4ckb0t</url>
Expand Down
7 changes: 6 additions & 1 deletion src/bl4ckscor3/bot/bl4ckb0t/Core.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package bl4ckscor3.bot.bl4ckb0t;

import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -9,6 +11,7 @@
import org.pircbotx.exception.IrcException;

import bl4ckscor3.bot.bl4ckb0t.logging.Logging;
import bl4ckscor3.bot.bl4ckb0t.misc.AGMaps;
import bl4ckscor3.bot.bl4ckb0t.util.Lists;
import bl4ckscor3.bot.bl4ckb0t.util.Passwords;

Expand All @@ -17,7 +20,7 @@ public class Core
public static Bot bot;
private static boolean wasStartedAsWIP;
private static final String botName = "bl4ckb0t";
private static final String version = "5.7.4";
private static final String version = "5.7.5";
private static ConfigurationFile customConfig;

public static void main(String args[]) throws IOException, IrcException
Expand Down Expand Up @@ -68,6 +71,8 @@ public static void createBot(boolean wip) throws IOException, IrcException
Lists.clearAll();
Startup.callMethods();
Logging.info("Completed last setup steps...");
Executors.newScheduledThreadPool(1).scheduleWithFixedDelay(new AGMaps(), 60, 60, TimeUnit.SECONDS);
Logging.info("Started AGMaps executor...");
Logging.info("Starting bot...");
bot.startBot();
}
Expand Down
52 changes: 52 additions & 0 deletions src/bl4ckscor3/bot/bl4ckb0t/misc/AGMaps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package bl4ckscor3.bot.bl4ckb0t.misc;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.pircbotx.Colors;

import bl4ckscor3.bot.bl4ckb0t.Core;
import bl4ckscor3.bot.bl4ckb0t.util.Utilities;

/**
* Checks for and sends the map of the aG-Community Skill Surf server incl. player amount
* @author bl4ckscor3, initial idea by Vauff
*/
public class AGMaps implements Runnable
{
/**The map played before the current one*/
private String previousMap;

public AGMaps()
{
previousMap = "";
}

@Override
public void run()
{
if(!Core.bot.isEnabled())
return;

try
{
Document doc = Jsoup.connect("http://cache.www.gametracker.com/components/html0/?host=csgo.area-community.net:27210&bgColor=333333&fontColor=CCCCCC&titleBgColor=222222&titleColor=FF9900&borderColor=555555&linkColor=FFCC00&borderLinkColor=222222&showMap=0&showCurrPlayers=0&showTopPlayers=0&showBlogs=0&width=240").userAgent("Mozilla").get();
String map = doc.select(".info_line_right > a:nth-child(1)").text();
String players = doc.select("div.info_line:nth-child(5) > div:nth-child(2)").text().split("/")[0];

if(!previousMap.equals(map) && !map.equals(""))
{
String message = "Now playing " + Colors.BOLD + Colors.DARK_GREEN + map;

if(!players.equals(""))
message += Colors.NORMAL + " with " + Colors.BOLD + Colors.OLIVE + players + " players " + Colors.NORMAL + "online.";

Utilities.sendMessage("#AGMaps", message);
previousMap = map;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

0 comments on commit c757a8d

Please sign in to comment.