v0.2
This commit is contained in:
parent
4c532a730c
commit
91dfb5a934
9 changed files with 20 additions and 8 deletions
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
|
@ -2,7 +2,7 @@ pipeline {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'maven:3-alpine'
|
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') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
|
// TODO: consider switch to docker registry
|
||||||
sh 'cp ./target/InnaIrcBot-*-jar-with-dependencies.jar /rel/InnaIrcBot.jar'
|
sh 'cp ./target/InnaIrcBot-*-jar-with-dependencies.jar /rel/InnaIrcBot.jar'
|
||||||
// sh 'docker restart innaircbot'
|
// sh 'docker restart innaircbot'
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>loper</groupId>
|
<groupId>loper</groupId>
|
||||||
<artifactId>InnaIrcBot</artifactId>
|
<artifactId>InnaIrcBot</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>InnaIrcBot</name>
|
<name>InnaIrcBot</name>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* InnaIrcBot
|
* InnaIrcBot
|
||||||
* @author Dmitry Isaenko
|
* @author Dmitry Isaenko
|
||||||
* @version 0.1 "Батлкрузер"
|
|
||||||
* Russia, 2018.
|
* Russia, 2018.
|
||||||
* */
|
* */
|
||||||
package InnaIrcBot;
|
package InnaIrcBot;
|
||||||
|
|
|
@ -151,13 +151,13 @@ public class ChanelCommander implements Runnable {
|
||||||
executiveStr.append(": ");
|
executiveStr.append(": ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i<messages.length; i++){
|
for (int i = 0; i < messages.length; i++){
|
||||||
if ( ! messages[i].startsWith("\\"))
|
if ( ! messages[i].startsWith("\\"))
|
||||||
executiveStr.append(messages[i]);
|
executiveStr.append(messages[i]);
|
||||||
else if (messages[i].equals("\\time"))
|
else if (messages[i].equals("\\time"))
|
||||||
executiveStr.append(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
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());
|
StreamProvider.writeToStream(server, executiveStr.toString());
|
||||||
}
|
}
|
||||||
private void banAction(String whom){
|
private void banAction(String whom){
|
||||||
|
@ -172,7 +172,7 @@ public class ChanelCommander implements Runnable {
|
||||||
executiveStr.append(simplifyNick(whom));
|
executiveStr.append(simplifyNick(whom));
|
||||||
executiveStr.append(" :");
|
executiveStr.append(" :");
|
||||||
|
|
||||||
for (int i = 1; i<messages.length; i++){
|
for (int i = 0; i < messages.length; i++){
|
||||||
if ( ! messages[i].startsWith("\\"))
|
if ( ! messages[i].startsWith("\\"))
|
||||||
executiveStr.append(messages[i]);
|
executiveStr.append(messages[i]);
|
||||||
else if (messages[i].equals("\\time"))
|
else if (messages[i].equals("\\time"))
|
||||||
|
@ -184,7 +184,7 @@ public class ChanelCommander implements Runnable {
|
||||||
// TSV
|
// TSV
|
||||||
private void parse(String[] directive){
|
private void parse(String[] directive){
|
||||||
if (directive.length >= 3 && directive[0] != null && !directive[0].startsWith("#") && directive[1] != null && directive[2] != null){
|
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()){
|
switch (directive[0].toLowerCase()){
|
||||||
case "join":
|
case "join":
|
||||||
joinMap.put(directive[1], Arrays.copyOfRange(directive, 2, directive.length));
|
joinMap.put(directive[1], Arrays.copyOfRange(directive, 2, directive.length));
|
||||||
|
|
|
@ -3,6 +3,7 @@ package InnaIrcBot.Config;
|
||||||
public class StorageFile {
|
public class StorageFile {
|
||||||
private final String serverName;
|
private final String serverName;
|
||||||
private final int serverPort;
|
private final int serverPort;
|
||||||
|
private final String serverPass;
|
||||||
private final String[] channels;
|
private final String[] channels;
|
||||||
private final String userNick;
|
private final String userNick;
|
||||||
private final String userIdent;
|
private final String userIdent;
|
||||||
|
@ -18,6 +19,7 @@ public class StorageFile {
|
||||||
|
|
||||||
public String getServerName() { return serverName; }
|
public String getServerName() { return serverName; }
|
||||||
public int getServerPort() { return serverPort; }
|
public int getServerPort() { return serverPort; }
|
||||||
|
public String getServerPass() { return serverPass; }
|
||||||
public String[] getChannels() { return channels; }
|
public String[] getChannels() { return channels; }
|
||||||
public String getUserNick() { return userNick; }
|
public String getUserNick() { return userNick; }
|
||||||
public String getUserIdent() { return userIdent; }
|
public String getUserIdent() { return userIdent; }
|
||||||
|
@ -33,6 +35,7 @@ public class StorageFile {
|
||||||
|
|
||||||
public StorageFile(String serverName,
|
public StorageFile(String serverName,
|
||||||
int serverPort,
|
int serverPort,
|
||||||
|
String serverPass,
|
||||||
String[] channels,
|
String[] channels,
|
||||||
String userNick,
|
String userNick,
|
||||||
String userIdent,
|
String userIdent,
|
||||||
|
@ -47,6 +50,7 @@ public class StorageFile {
|
||||||
String chanelConfigurationsPath){
|
String chanelConfigurationsPath){
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.serverPort = serverPort;
|
this.serverPort = serverPort;
|
||||||
|
this.serverPass = serverPass;
|
||||||
this.channels = channels;
|
this.channels = channels;
|
||||||
this.userIdent = userIdent;
|
this.userIdent = userIdent;
|
||||||
this.userNick = userNick;
|
this.userNick = userNick;
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class StorageReader {
|
||||||
|
|
||||||
StorageFile storageFileObject = new StorageFile("srv",
|
StorageFile storageFileObject = new StorageFile("srv",
|
||||||
6667,
|
6667,
|
||||||
|
"",
|
||||||
new String[] {"#lpr",
|
new String[] {"#lpr",
|
||||||
"#main"},
|
"#main"},
|
||||||
"user_nick",
|
"user_nick",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package InnaIrcBot;
|
package InnaIrcBot;
|
||||||
|
|
||||||
public class GlobalData {
|
public class GlobalData {
|
||||||
public static final String version = "InnaIrcBot v0.1 \"Батлкрузер\"";
|
public static final String version = "InnaIrcBot v0.2 \"Маньчжурия\"";
|
||||||
public static synchronized String getAppVersion(){
|
public static synchronized String getAppVersion(){
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,8 @@ public class DataProvider implements Runnable {
|
||||||
|
|
||||||
StreamProvider.writeToStream(serverName,"NICK "+this.userNick);
|
StreamProvider.writeToStream(serverName,"NICK "+this.userNick);
|
||||||
StreamProvider.writeToStream(serverName,"USER "+configFile.getUserIdent()+" 8 * :"+configFile.getUserRealName()); // TODO: Add usermode 4 rusnet
|
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")))
|
if (!configFile.getUserNickPass().isEmpty() && (!configFile.getUserNickAuthStyle().isEmpty() && configFile.getUserNickAuthStyle().toLowerCase().equals("freenode")))
|
||||||
StreamProvider.writeToStream(serverName,"PRIVMSG NickServ :IDENTIFY "+configFile.getUserNickPass());
|
StreamProvider.writeToStream(serverName,"PRIVMSG NickServ :IDENTIFY "+configFile.getUserNickPass());
|
||||||
|
@ -186,6 +188,7 @@ public class DataProvider implements Runnable {
|
||||||
// 432 ERR_ERRONEUSNICKNAME covered
|
// 432 ERR_ERRONEUSNICKNAME covered
|
||||||
// 433 ERR_NICKNAMEINUSE covered
|
// 433 ERR_NICKNAMEINUSE covered
|
||||||
// 436 ERR_NICKCOLLISION
|
// 436 ERR_NICKCOLLISION
|
||||||
|
// 464 ERR_PASSWDMISMATCH (password for server/znc/bnc)
|
||||||
while ((rawMessage = genericStreamReader.readLine()) != null){
|
while ((rawMessage = genericStreamReader.readLine()) != null){
|
||||||
System.out.println(rawMessage);
|
System.out.println(rawMessage);
|
||||||
if (rawMessage.startsWith("PING :")) {
|
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).");
|
System.out.println("Configuration issue: Nickname contains unacceptable characters (432 ERR_ERRONEUSNICKNAME).");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (rawMessage.contains(" 464 ")) {
|
||||||
|
StreamProvider.writeToStream(serverName,"PASS "+configFile.getServerPass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
System.out.println("Internal issue: DataProvider->initConnection() caused I/O exception.");
|
System.out.println("Internal issue: DataProvider->initConnection() caused I/O exception.");
|
||||||
|
|
|
@ -7,6 +7,7 @@ public class StorageFileTest {
|
||||||
StorageFile config = new StorageFile(
|
StorageFile config = new StorageFile(
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
|
"",
|
||||||
null,
|
null,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
Loading…
Reference in a new issue