Skip to content

Commit e2633a5

Browse files
committed
Working monocle support (tested on Hydro74000) + new features
Only store messages if logging is enabled new config vars: - Renamed useRmDb to useScanDb - maxStoredMessages used to limit the amount of messages to store at any time, only used if logging is enabled. - protocol and useSSL parameters added to both [scanner db] and [novabot db] blocks, defaults to mysql and true respectively new team icons (valor, uncontested, mystic, instinct) new substitutions: - team_icon for raids - quick_move_type and charge_move_type - quick_move_type_icon and charge_move_type_icon Improved error catching/handling. Fixed some typos + more
1 parent c022d79 commit e2633a5

37 files changed

+879
-1080
lines changed

README.MD

+8-664
Large diffs are not rendered by default.

config.example.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
token =
33
blacklist = [13, 16, 19, 21, 23, 29, 32, 41, 48, 60, 98, 115, 118, 120, 183, 161, 165, 167, 177, 194, 198]
44
raidBosses = [2,5,8,11,28,31,34,38,62,65,68,71,73,76,82,91,94,105,123,129,131,137,139,143,144,145,146,150,243,244,245,248,249,302,303,359]
5-
useRmDb = true
5+
useScanDb = true
66
scannerType = rocketmap
77
googleSuburbField = city
88
pokemon = true

formatting.ini

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
encounteredTitle = [<city>] <pkmn> <form>
33
title = [<city>] <pkmn> <form>
44
titleUrl = <gmaps>
5-
encounteredBody = **Available until: <24h_time> (<time_left>)**\n\nLvl30+ IVs: <atk>A/<def>D/<sta>S (<iv>%)\nLvl30+ CP: <cp> (lvl <level>)\nLvl30+ Moveset: <quick_move> - <charge_move>\nGender: <gender>, Height: <height>, Weight: <weight>
5+
encounteredBody = **Available until: <24h_time> (<time_left>)**\n\nLvl30+ IVs: <atk>A/<def>D/<sta>S (<iv>%)\nLvl30+ CP: <cp> (lvl <level>)\nLvl30+ Moveset: <quick_move><quick_move_type_icon> - <charge_move><charge_move_type_icon>\nGender: <gender>, Height: <height>, Weight: <weight>
66
body = **Available until: <24h_time> (<time_left>)**\n\n
7-
content = <@&1028313314183>
87
showMap = true
98
mapZoom = 15
109
mapWidth = 255
1110
mapHeight = 225
1211
[raidEgg]
1312
title = [<city>] Level <level> raid
1413
titleUrl = <gmaps>
15-
body = **Raid will start at <24h_start> (<time_left_start>)**\n**Gym Name:** <gym_name>
14+
body = **Raid will start at <24h_start> (<time_left_start>)**\n**Gym Name:** <gym_name>\n**Gym Owners:** <team_name> <team_icon>
1615
showMap = true
1716
mapZoom = 15
1817
mapWidth = 255
1918
mapHeight = 225
2019
[raidBoss]
2120
title = [<city>] <pkmn> raid (lvl <level>)
2221
titleUrl = <gmaps>
23-
body = **Available until <24h_end> (<time_left>)**\n**Gym Name:** <gym_name> \n**CP:** <cp>\n**Moveset:** <quick_move> - <charge_move>
22+
body = **Available until <24h_end> (<time_left>)**\n**Gym Name:** <gym_name> \n**Gym Owners:** <team_name> <team_icon>\n**CP:** <cp>\n**Moveset:** <quick_move><quick_move_type_icon> - <charge_move><charge_move_type_icon>
2423
showMap = true
2524
mapZoom = 15
2625
mapWidth = 255

gkeys.txt

Whitespace-only changes.

src/core/Config.java

+54-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.ini4j.Ini;
1616
import pokemon.PokeSpawn;
1717
import pokemon.Pokemon;
18-
import raids.Raid;
1918
import raids.RaidSpawn;
2019

2120
import java.io.File;
@@ -25,8 +24,6 @@
2524
import java.time.ZoneId;
2625
import java.util.*;
2726

28-
import static raids.Raid.emotes;
29-
3027
/**
3128
* Created by Owner on 13/05/2017.
3229
*/
@@ -48,7 +45,7 @@ public class Config {
4845
private boolean startupMessage = false;
4946
private boolean countLocationsInLimits = true;
5047
private ScannerType scannerType = ScannerType.RocketMap;
51-
private boolean useRmDb = true;
48+
private boolean useScanDb = true;
5249
private boolean raidsEnabled = true;
5350
private boolean pokemonEnabled = true;
5451
private boolean raidOrganisationEnabled = true;
@@ -67,16 +64,19 @@ public class Config {
6764
private String scanPort = "3306";
6865
private String scanDbName;
6966
private String scanProtocol = "mysql";
67+
private String scanUseSSL = "true";
7068
private String nbUser;
7169
private String nbPass;
7270
private String nbIp;
7371
private String nbPort = "3306";
7472
private String nbDbName;
7573
private String nbProtocol = "mysql";
74+
private String nbUseSSL = "true";
7675
private long pokePollingDelay = 2;
7776
private long raidPollingDelay = 15;
7877
private int pokemonThreads = 2;
7978
private int raidThreads = 2;
79+
private int maxStoredMessages = 1000000;
8080
private NotificationLimit nonSupporterLimit = new NotificationLimit(null, null, null);
8181
private ArrayList<String> GMAPS_KEYS = new ArrayList<>();
8282
private HashMap<GeofenceIdentifier, String> raidChats = new HashMap<>();
@@ -109,7 +109,7 @@ public Config(Ini configIni, NovaBot novaBot) {
109109
raidBosses.add(Integer.valueOf(s));
110110
}
111111

112-
useRmDb = config.get("useRmDb", Boolean.class, useRmDb);
112+
useScanDb = config.get("useScanDb", Boolean.class, useScanDb);
113113

114114
scannerType = ScannerType.fromString(config.get("scannerType",scannerType.toString()));
115115

@@ -133,10 +133,12 @@ public Config(Ini configIni, NovaBot novaBot) {
133133

134134
countLocationsInLimits = config.get("countLocationsInLimits", Boolean.class, countLocationsInLimits);
135135

136-
137136
logging = config.get("logging", Boolean.class, logging);
138137

138+
139139
if (logging) {
140+
maxStoredMessages = config.get("maxStoredMessages",Integer.class, maxStoredMessages);
141+
140142
roleLogId = config.get("roleLogChannel", roleLogId);
141143

142144
userUpdatesId = config.get("userUpdatesChannel", userUpdatesId);
@@ -180,6 +182,7 @@ public Config(Ini configIni, NovaBot novaBot) {
180182
scanPort = scannerDb.get("port", scanPort);
181183
scanDbName = scannerDb.get("dbName", scanDbName);
182184
scanProtocol = scannerDb.get("protocol", scanProtocol);
185+
scanUseSSL = scannerDb.get("useSSL",scanUseSSL);
183186

184187
Ini.Section novabotDb = configIni.get("novabot db");
185188
nbUser = novabotDb.get("user", nbUser);
@@ -188,6 +191,7 @@ public Config(Ini configIni, NovaBot novaBot) {
188191
nbPort = novabotDb.get("port", nbPort);
189192
nbDbName = novabotDb.get("dbName", nbDbName);
190193
nbProtocol = novabotDb.get("protocol", nbProtocol);
194+
nbUseSSL = novabotDb.get("useSSL",nbUseSSL);
191195

192196
novaBot.novabotLog.info("Finished loading config.ini");
193197

@@ -253,7 +257,11 @@ public ArrayList<String> findMatchingPresets(PokeSpawn pokeSpawn) {
253257
public String formatStr(HashMap<String, String> properties, String toFormat) {
254258
final String[] str = {toFormat};
255259

256-
properties.forEach((key, value) -> str[0] = str[0].replace(String.format("<%s>", key), value));
260+
for (Map.Entry<String, String> stringStringEntry : properties.entrySet()) {
261+
str[0] = str[0].replace(String.format("<%s>", stringStringEntry.getKey()), stringStringEntry.getValue());
262+
}
263+
264+
// properties.forEach((key, value) -> str[0] = str[0].replace(String.format("<%s>", key), value));
257265

258266
return str[0];
259267
}
@@ -483,18 +491,33 @@ public boolean isRaidOrganisationEnabled() {
483491
}
484492

485493
public void loadEmotes() {
486-
for (String type : Raid.TYPES) {
494+
for (String type : Types.TYPES) {
487495
List<Emote> found = novaBot.jda.getEmotesByName(type, true);
488496
if (found.size() == 0) try {
489497
novaBot.guild.getController().createEmote(type, Icon.from(new File("static/icons/" + type + ".png"))).queue(emote ->
490-
emotes.put(type, emote));
498+
Types.emotes.put(type, emote));
499+
} catch (IOException e) {
500+
e.printStackTrace();
501+
}
502+
else {
503+
Types.emotes.put(type, found.get(0));
504+
}
505+
}
506+
novaBot.novabotLog.info(String.format("Finished loading type emojis: %s", Types.emotes.toString()));
507+
508+
for (Team team : Team.values()) {
509+
List<Emote> found = novaBot.jda.getEmotesByName(team.toString().toLowerCase(), true);
510+
if (found.size() == 0) try {
511+
novaBot.guild.getController().createEmote(team.toString().toLowerCase(), Icon.from(new File("static/icons/" + team.toString().toLowerCase() + ".png"))).queue(emote ->
512+
Team.emotes.put(team, emote));
491513
} catch (IOException e) {
492514
e.printStackTrace();
493515
}
494516
else {
495-
emotes.put(type, found.get(0));
517+
Team.emotes.put(team, found.get(0));
496518
}
497519
}
520+
novaBot.novabotLog.info(String.format("Finished loading team emojis: %s", Team.emotes.toString()));
498521
}
499522

500523
public boolean loggingEnabled() {
@@ -504,18 +527,23 @@ public boolean loggingEnabled() {
504527
public static void main(String[] args) {
505528
NovaBot novaBot = new NovaBot();
506529
novaBot.setup();
507-
System.out.println(novaBot.config.token);
530+
System.out.println(Util.getCurrentTime(ZoneId.of("+02:00")));
531+
novaBot.config.matchesFilter(novaBot.config.raidFilters.get("raidfilter.json"),new RaidSpawn(383,5,false));
508532
}
509533

510534
public boolean matchesFilter(JsonObject filter, RaidSpawn raidSpawn) {
511535
String searchStr = (raidSpawn.bossId >= 1) ? Pokemon.getFilterName(raidSpawn.bossId) : "Egg" + raidSpawn.raidLevel;
512536

513537
JsonElement raidFilter = searchFilter(filter, searchStr);
514538
if (raidFilter == null) {
539+
RaidNotificationSender.notificationLog.info(String.format("couldn't find filter for '%s'",searchStr));
515540
// System.out.println(String.format("raidFilter %s is null for %s for channel with id %s", channel.filterName, searchStr,channel.channelId));
516541
raidFilter = searchFilter(filter, "Level" + raidSpawn.raidLevel);
517542

518-
if (raidFilter == null) return false;
543+
if (raidFilter == null) {
544+
RaidNotificationSender.notificationLog.info(String.format("couldn't find filter for '%s'","Level" + raidSpawn.raidLevel));
545+
return false;
546+
}
519547
}
520548

521549
if (raidFilter.isJsonObject()) {
@@ -653,8 +681,8 @@ public boolean useGeofences() {
653681
return Geofencing.notEmpty();
654682
}
655683

656-
public boolean useRmDb() {
657-
return useRmDb;
684+
public boolean useScanDb() {
685+
return useScanDb;
658686
}
659687

660688
private void loadFilter(String filterName, HashMap<String, JsonObject> filterMap) {
@@ -1127,4 +1155,16 @@ public String getNbProtocol() {
11271155
public String getScanProtocol() {
11281156
return scanProtocol;
11291157
}
1158+
1159+
public String getScanUseSSL() {
1160+
return scanUseSSL;
1161+
}
1162+
1163+
public String getNbUseSSL() {
1164+
return nbUseSSL;
1165+
}
1166+
1167+
public int getMaxStoredMessages() {
1168+
return maxStoredMessages;
1169+
}
11301170
}

0 commit comments

Comments
 (0)