Permalink
Browse files

Squash existing history for public release

Signed-off-by: Tom Brookes <me@iaero.me>
  • Loading branch information...
aerouk committed Jul 18, 2018
0 parents commit 5d2395b8f133ba7ec94ea71115a2ae23883e1996
Showing with 1,342 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +14 −0 .travis.yml
  3. +23 −0 README.md
  4. +92 −0 pom.xml
  5. +17 −0 resources/logback.xml
  6. +119 −0 src/main/java/me/iaero/twitchbot/App.java
  7. +85 −0 src/main/java/me/iaero/twitchbot/Config.java
  8. +70 −0 src/main/java/me/iaero/twitchbot/commands/Command.java
  9. +30 −0 src/main/java/me/iaero/twitchbot/commands/admin/ShutdownCommand.java
  10. +34 −0 src/main/java/me/iaero/twitchbot/commands/fortnite/FNStatsCommand.java
  11. +57 −0 src/main/java/me/iaero/twitchbot/commands/osu/LastCommand.java
  12. +61 −0 src/main/java/me/iaero/twitchbot/commands/osu/RankCommand.java
  13. +51 −0 src/main/java/me/iaero/twitchbot/commands/osu/TopRankCommand.java
  14. +25 −0 src/main/java/me/iaero/twitchbot/handlers/BotListenerAdapter.java
  15. +76 −0 src/main/java/me/iaero/twitchbot/handlers/CommandManager.java
  16. +18 −0 src/main/java/me/iaero/twitchbot/handlers/CommandModuleHandler.java
  17. +85 −0 src/main/java/me/iaero/twitchbot/handlers/ListenerHandler.java
  18. +36 −0 src/main/java/me/iaero/twitchbot/handlers/ModuleHandler.java
  19. +52 −0 src/main/java/me/iaero/twitchbot/helpers/FortniteHelper.java
  20. +140 −0 src/main/java/me/iaero/twitchbot/helpers/OsuHelper.java
  21. +78 −0 src/main/java/me/iaero/twitchbot/helpers/PermsHelper.java
  22. +47 −0 src/main/java/me/iaero/twitchbot/listeners/CommandListener.java
  23. +12 −0 src/main/java/me/iaero/twitchbot/models/OsuBeatmap.java
  24. +40 −0 src/main/java/me/iaero/twitchbot/models/OsuScore.java
  25. +30 −0 src/main/java/me/iaero/twitchbot/models/OsuUser.java
  26. +38 −0 src/test/java/me/iaero/twitchbot/AppTest.java
@@ -0,0 +1,12 @@
.project
.metadata
bin/
tmp/
*.tmp
*.properties
.classpath
.settings/
target/

*.iml
.idea/
@@ -0,0 +1,14 @@
language: java
sudo: false
jobs:
include:
- script: mvn clean package
- stage: GitHub Release
script: echo "Deploying to GitHub releases ..."
deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
file: "target/twitchbot-jar-with-dependencies.jar"
skip_cleanup: true
on:
tags: true
@@ -0,0 +1,23 @@
# twitch-bot ![](https://travis-ci.com/aerouk/twitch-bot.svg?token=zf7QrH3hskS9v9YTakTV&branch=master)

Re-implementation of my twitch bot, previously running on python alongside sopel.

### Code Style

- Wrap comments and javadoc after 80 characters
- Any code that goes massively over 80 characters should be wrapped, as shown in the example below.
- If using multiple lines for parameters, insert a line break, as shown below.

```java
public void method(String param, int otherParam)
{
if (condition) {
doSomething();
} else {
otherMethod(
param1, param2, param3, param4, param5,
param6, param7, youGetTheGist
);
}
}
```
92 pom.xml
@@ -0,0 +1,92 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me.iaero.twitchbot</groupId>
<artifactId>twitchbot</artifactId>
<version>0.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>twitchbot</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>

<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

<archive>
<manifest>
<mainClass>me.iaero.twitchbot.App</mainClass>
</manifest>
</archive>
</configuration>

<executions>
<execution>
<phase>package</phase>

<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<finalName>twitchbot</finalName>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.pircbotx</groupId>
<artifactId>pircbotx</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>
</dependency>

<!-- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>-->
</dependencies>
</project>
@@ -0,0 +1,17 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n</Pattern>
</layout>
</appender>

<logger name="org.pircbotx.PircBotX" level="ERROR" />
<logger name="org.pircbotx.InputParser" level="ERROR" />
<logger name="org.pircbotx.output.OutputRaw" level="ERROR" />
<logger name="org.pircbotx.dcc.Chat" level="ERROR" />
<logger name="org.pircbotx.dcc.ReceiveChat" level="ERROR" />

<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
@@ -0,0 +1,119 @@
package me.iaero.twitchbot;

import me.iaero.twitchbot.commands.admin.ShutdownCommand;
import me.iaero.twitchbot.commands.fortnite.FNStatsCommand;
import me.iaero.twitchbot.commands.osu.LastCommand;
import me.iaero.twitchbot.commands.osu.RankCommand;
import me.iaero.twitchbot.commands.osu.TopRankCommand;
import me.iaero.twitchbot.handlers.CommandManager;
import me.iaero.twitchbot.handlers.CommandModuleHandler;
import me.iaero.twitchbot.handlers.ListenerHandler;
import org.pircbotx.Configuration;
import org.pircbotx.PircBotX;

import java.util.Arrays;
import java.util.List;

/**
* The main bot application class.
*
* @author Tom Brookes
* @version 18.03.2017
*/
public class App
{
private static CommandManager commandManager;
private static ListenerHandler listenerHandler;
private static Config iconfig;
private static PircBotX bot;

public static void main(String[] args) throws Exception
{
commandManager = new CommandManager();
listenerHandler = new ListenerHandler();
iconfig = new Config();

new CommandModuleHandler();

registerCommands();
commandManager.printCommands();

List<String> channels = Arrays.asList(iconfig.getProps().getProperty("ircChannels").split(","));

Configuration.Builder builder = new Configuration.Builder()
// adds the configured server, parsing the port
// if no port provided, 6667 will be used
.addServer(
iconfig.getProps().getProperty("ircServer"),
Integer.parseInt(iconfig.getProps().getProperty("ircPort", "6667")))
.setServerPassword(iconfig.getProps().getProperty("ircPassword"))
.setName(iconfig.getProps().getProperty("ircUsername"))
.setLogin(iconfig.getProps().getProperty("ircUsername"))
.setRealName(iconfig.getProps().getProperty("ircUsername"))
.setListenerManager(listenerHandler.getManager())
.addAutoJoinChannels(channels);

Configuration config = builder.buildConfiguration();
bot = new PircBotX(config);

bot.startBot();
bot.close();
}

/**
* Registers all available commands.
*/
private static void registerCommands()
{
// admin commands
new ShutdownCommand();

// osu commands
new LastCommand(); // last, osulast
new RankCommand(); // osu, osurank
new TopRankCommand(); // top, osutop

// fortnite commands
new FNStatsCommand(); // fn, fnstats
}

/**
* Gets the bot's command manager.
*
* @return command manager
*/
public static CommandManager getCommandManager()
{
return commandManager;
}

/**
* Gets the bot's listener handler.
*
* @return active listener handler
*/
public static ListenerHandler getListenerHandler()
{
return listenerHandler;
}

/**
* Gets the bot config.
*
* @return bot configuration
*/
public static Config getConfig()
{
return iconfig;
}

/**
* Gets the bot.
*
* @return the bot
*/
public static PircBotX getBot()
{
return bot;
}
}
@@ -0,0 +1,85 @@
package me.iaero.twitchbot;

import java.io.*;
import java.util.Properties;

/**
* Represents a configuration file.
*
* @author Tom Brookes
* @version 19.10.2017
*/
public class Config
{
private Properties props;

/**
* Sets up a new config file if one does not exist.
*/
Config()
{
if (!configExists()) createConfig();

props = getConfig();
}

/**
* Creates a new configuration file with default options.
*/
private void createConfig()
{
Properties props = new Properties();

try (OutputStream output = new FileOutputStream("config.properties", true)) {
props.setProperty("osuAPI", "");
props.setProperty("fnTrackerAPI", "");
props.setProperty("ircServer", "irc.chat.twitch.tv");
props.setProperty("ircUsername", "");
props.setProperty("ircPassword", "");
props.setProperty("ircChannels", "#example");
props.setProperty("msgCooldown", "2");

props.store(output, null);
} catch (IOException ignored) {
}
}

/**
* Returns whether the configuration file already exists.
*
* @return whether config file already exists
*/
private boolean configExists()
{
File file = new File("config.properties");

return file.exists();
}

/**
* Gets the properties inside the config file.
*
* @return properties of config file
*/
private Properties getConfig()
{
Properties props = new Properties();

try (InputStream input = new FileInputStream("config.properties")) {
props.load(input);
} catch (IOException ignored) {
}

return props;
}

/**
* Gets the properties.
*
* @return properties of config
*/
public Properties getProps()
{
return props;
}
}
Oops, something went wrong.

0 comments on commit 5d2395b

Please sign in to comment.