master
Dmitry Isaenko 2019-01-02 15:25:04 +03:00
parent 4c532a730c
commit 91dfb5a934
9 changed files with 20 additions and 8 deletions

3
Jenkinsfile vendored
View File

@ -2,7 +2,7 @@ pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2 -v /home/docker/innaircbot/files/artifact:/rel'
args '-v /home/docker/jenkins/files/m2:/root/.m2 -v /home/docker/innaircbot/files/artifact:/rel'
}
}
@ -19,6 +19,7 @@ pipeline {
}
stage('Deploy') {
steps {
// TODO: consider switch to docker registry
sh 'cp ./target/InnaIrcBot-*-jar-with-dependencies.jar /rel/InnaIrcBot.jar'
// sh 'docker restart innaircbot'
}

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>loper</groupId>
<artifactId>InnaIrcBot</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>InnaIrcBot</name>

View File

@ -1,7 +1,6 @@
/**
* InnaIrcBot
* @author Dmitry Isaenko
* @version 0.1 "Батлкрузер"
* Russia, 2018.
* */
package InnaIrcBot;

View File

@ -151,13 +151,13 @@ public class ChanelCommander implements Runnable {
executiveStr.append(": ");
}
for (int i = 1; i<messages.length; i++){
for (int i = 0; i < messages.length; i++){
if ( ! messages[i].startsWith("\\"))
executiveStr.append(messages[i]);
else if (messages[i].equals("\\time"))
executiveStr.append(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
//System.out.println(executiveStr); //TODO: debug
//System.out.println(executiveStr.toString()); //TODO: debug
StreamProvider.writeToStream(server, executiveStr.toString());
}
private void banAction(String whom){
@ -172,7 +172,7 @@ public class ChanelCommander implements Runnable {
executiveStr.append(simplifyNick(whom));
executiveStr.append(" :");
for (int i = 1; i<messages.length; i++){
for (int i = 0; i < messages.length; i++){
if ( ! messages[i].startsWith("\\"))
executiveStr.append(messages[i]);
else if (messages[i].equals("\\time"))
@ -184,7 +184,7 @@ public class ChanelCommander implements Runnable {
// TSV
private void parse(String[] directive){
if (directive.length >= 3 && directive[0] != null && !directive[0].startsWith("#") && directive[1] != null && directive[2] != null){
//System.out.println(Arrays.toString(directive)); // TODO:debug
// System.out.println(Arrays.toString(directive)); // TODO:debug
switch (directive[0].toLowerCase()){
case "join":
joinMap.put(directive[1], Arrays.copyOfRange(directive, 2, directive.length));

View File

@ -3,6 +3,7 @@ package InnaIrcBot.Config;
public class StorageFile {
private final String serverName;
private final int serverPort;
private final String serverPass;
private final String[] channels;
private final String userNick;
private final String userIdent;
@ -18,6 +19,7 @@ public class StorageFile {
public String getServerName() { return serverName; }
public int getServerPort() { return serverPort; }
public String getServerPass() { return serverPass; }
public String[] getChannels() { return channels; }
public String getUserNick() { return userNick; }
public String getUserIdent() { return userIdent; }
@ -33,6 +35,7 @@ public class StorageFile {
public StorageFile(String serverName,
int serverPort,
String serverPass,
String[] channels,
String userNick,
String userIdent,
@ -47,6 +50,7 @@ public class StorageFile {
String chanelConfigurationsPath){
this.serverName = serverName;
this.serverPort = serverPort;
this.serverPass = serverPass;
this.channels = channels;
this.userIdent = userIdent;
this.userNick = userNick;

View File

@ -65,6 +65,7 @@ public class StorageReader {
StorageFile storageFileObject = new StorageFile("srv",
6667,
"",
new String[] {"#lpr",
"#main"},
"user_nick",

View File

@ -1,7 +1,7 @@
package InnaIrcBot;
public class GlobalData {
public static final String version = "InnaIrcBot v0.1 \"Батлкрузер\"";
public static final String version = "InnaIrcBot v0.2 \"Маньчжурия\"";
public static synchronized String getAppVersion(){
return version;
}

View File

@ -173,6 +173,8 @@ public class DataProvider implements Runnable {
StreamProvider.writeToStream(serverName,"NICK "+this.userNick);
StreamProvider.writeToStream(serverName,"USER "+configFile.getUserIdent()+" 8 * :"+configFile.getUserRealName()); // TODO: Add usermode 4 rusnet
if (!configFile.getServerPass().isEmpty())
StreamProvider.writeToStream(serverName,"PASS "+configFile.getServerPass());
if (!configFile.getUserNickPass().isEmpty() && (!configFile.getUserNickAuthStyle().isEmpty() && configFile.getUserNickAuthStyle().toLowerCase().equals("freenode")))
StreamProvider.writeToStream(serverName,"PRIVMSG NickServ :IDENTIFY "+configFile.getUserNickPass());
@ -186,6 +188,7 @@ public class DataProvider implements Runnable {
// 432 ERR_ERRONEUSNICKNAME covered
// 433 ERR_NICKNAMEINUSE covered
// 436 ERR_NICKCOLLISION
// 464 ERR_PASSWDMISMATCH (password for server/znc/bnc)
while ((rawMessage = genericStreamReader.readLine()) != null){
System.out.println(rawMessage);
if (rawMessage.startsWith("PING :")) {
@ -223,6 +226,9 @@ public class DataProvider implements Runnable {
System.out.println("Configuration issue: Nickname contains unacceptable characters (432 ERR_ERRONEUSNICKNAME).");
return false;
}
else if (rawMessage.contains(" 464 ")) {
StreamProvider.writeToStream(serverName,"PASS "+configFile.getServerPass());
}
}
} catch (IOException e){
System.out.println("Internal issue: DataProvider->initConnection() caused I/O exception.");

View File

@ -7,6 +7,7 @@ public class StorageFileTest {
StorageFile config = new StorageFile(
"",
0,
"",
null,
"",
"",