Skip to content

Commit

Permalink
Merge pull request #103 from rwth-acis/release/1.4.0
Browse files Browse the repository at this point in the history
Release/1.4.0
  • Loading branch information
AlexanderNeumann authored Jan 10, 2022
2 parents 72f5ba3 + a8f1feb commit b0bc16f
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 51 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
Expand All @@ -13,6 +18,7 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:14-jdk-alpine
FROM openjdk:17-jdk-alpine

ENV LAS2PEER_PORT=9011
ENV DATABASE_NAME=SBF
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fi

# prevent glob expansion in lib/*
set -f
LAUNCH_COMMAND='java -cp lib/* i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}"
LAUNCH_COMMAND='java -cp lib/* --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}"
if [[ ! -z "${BOOTSTRAP}" ]]; then
LAUNCH_COMMAND="${LAUNCH_COMMAND} -b ${BOOTSTRAP}"
fi
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
core.version=1.1.2
core.version=1.2.0
service.name=i5.las2peer.services.socialBotManagerService
service.class=SocialBotManagerService
service.version=1.0.0
java.version=14
java.version=17

las2peer_user1.name=alice
las2peer_user1.password=pwalice
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
39 changes: 15 additions & 24 deletions social-bot-manager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ plugins {

repositories {
// Use JCenter for resolving dependencies.
jcenter()
mavenCentral()

// DBIS Archiva
maven {
url "https://archiva.dbis.rwth-aachen.de:9911/repository/internal/"
}

maven {
url "https://archiva.dbis.rwth-aachen.de:9911/repository/snapshots/"
}
}

dependencies {
Expand All @@ -20,7 +24,7 @@ dependencies {

// las2peer bundle which is not necessary in the runtime path
// compileOnly will be moved into the lib dir afterwards
compileOnly "i5:las2peer-bundle:${project.property('core.version')}"
implementation "i5:las2peer-bundle:${project.property('core.version')}"

// Add service dependencies here
// example:
Expand Down Expand Up @@ -48,7 +52,7 @@ dependencies {

configurations {
// This ensures las2peer is available in the tests, but won't be bundled
testCompile.extendsFrom compileOnly
testImplementation.extendsFrom implementation
}

jar {
Expand All @@ -72,14 +76,15 @@ application {
archivesBaseName = group

version = "${project.property('service.version')}"
mainClassName = "i5.las2peer.tools.L2pNodeLauncher"
mainClass.set("i5.las2peer.tools.L2pNodeLauncher")
sourceCompatibility = "${project.property('java.version')}"
targetCompatibility = "${project.property('java.version')}"
}

// put all .jar files into export/jars folder
tasks.withType(Jar) {
destinationDir = file("$projectDir/export/jars")
duplicatesStrategy = 'include'
destinationDirectory = file("$projectDir/export/jars")
}

javadoc {
Expand Down Expand Up @@ -130,7 +135,7 @@ task startscripts {
# this script is autogenerated by 'gradle startscripts'
# it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project
# pls execute it from the root folder of your deployment, e. g. ./bin/start_network.sh
java -cp "lib/*" i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService\\(\\'${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}\\'\\) startWebConnector interactive
java -cp "lib/*" --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService\\(\\'${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}\\'\\) startWebConnector interactive
"""
new File("$rootDir/bin", "start_network.bat").text = """:: this script is autogenerated by 'gradle startscripts'
:: it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project
Expand All @@ -140,7 +145,9 @@ cd %~p0
cd ..
set BASE=%CD%
set CLASSPATH="%BASE%/lib/*;"
java -cp %CLASSPATH% i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService('${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}') startWebConnector interactive
set L2P_JAR_PATH="%BASE%/lib/las2peer-bundle-${project.property('core.version')}.jar"
java -cp %CLASSPATH% -jar %L2P_JAR_PATH% --port 9011 --service-directory service uploadStartupDirectory startService('${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}') startWebConnector interactive
pause
"""
}
Expand Down Expand Up @@ -256,20 +263,4 @@ test {

// Only required when using Eclipse:
// configuration for eclipse (this allows to import the project as a gradle project in eclipse without any problems)
eclipse {
classpath {
file {
whenMerged {
// change output directory for test, main, resources and default
def main = entries.find { it.path == "src/main/java" }
main.output = "output/main"

def test = entries.find { it.path == "src/test/java" }
test.output = "output/test"

def defaultEntry = entries.find { it.kind == "output" && it.path == "bin/default" }
defaultEntry.path = "output/default"
}
}
}
}
//
Original file line number Diff line number Diff line change
Expand Up @@ -1540,16 +1540,21 @@ public void triggerChat(ChatMediator chat, JSONObject body) {
channel = chat.getChannelByEmail(email);
}
System.out.println(channel);
if (text != null) {
if (text != null && !body.containsKey("fileBody")) {
chat.sendMessageToChannel(channel, text);
}
if (body.containsKey("blocks")) {
System.out.println("body has blocks");
chat.sendBlocksMessageToChannel(channel, blocks);
}
if (body.containsKey("fileBody")) {
if (text == null){

text = "" ;
}
System.out.println("text is sss" + text);
chat.sendFileMessageToChannel(channel, body.getAsString("fileBody"), body.getAsString("fileName"),
body.getAsString("fileType"), "");
body.getAsString("fileType"), text);
}
}
}
Expand Down Expand Up @@ -2210,9 +2215,13 @@ public static String encryptThisString(String input) {
String hashtext = no.toString(16);

// Add preceding 0s to make it 32 bit
while (hashtext.length() < 32) {
try{
while (hashtext.getBytes("UTF-16BE").length * 8 < 1536) {
hashtext = "0" + hashtext;
}
} catch (Exception e){
System.out.println(e);
}

// return the HashText
return hashtext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void sendFileMessageToChannel(String channel, String fileBody, String fil
* @param fileType Type of the file to be generated
* @param text Text to be sent with file
*/
public void sendFileMessageToChannel(String channel, String fileBody, String fileName, String text,
String fileType) {
public void sendFileMessageToChannel(String channel, String fileBody, String fileName, String fileType,
String text) {
sendFileMessageToChannel(channel, fileBody, fileName, fileType, text, Optional.empty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void sendFileMessageToChannel(String channel, File f, String text, Option
}

@Override
public void sendFileMessageToChannel(String channel, String fileBody, String fileName, String text, String fileType,
public void sendFileMessageToChannel(String channel, String fileBody, String fileName, String fileType, String text,
Optional<String> id) {
byte[] decodedBytes = java.util.Base64.getDecoder().decode(fileBody);
File file = new File(fileName + "." + fileType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void handle(RocketChatMessage message, int role, String email) {
String user = message.getSender().getUserName();
String msg = replaceUmlaute(message.getMessage());
ChatMessage cm = new ChatMessage(rid, user, msg);
System.out.println("Email of user is " + email);
cm.setEmail(email);
cm.setRole(role);
// timestamp
cm.setTime(message.getMsgTimestamp().toInstant().toString());
// domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ public void sendFileMessageToChannel(String channel, File f, String text, Option
FilesUploadResponse response2;
try {
response2 = slack.methods(authToken).filesUpload(req -> req.channels(channels).file(f)
.content("Pretty stuff").filename(f.getName()).title(f.getName()));
System.out.println("File sent: " + response2.isOk());
.content("Pretty stuff").filename(f.getName()).title(f.getName()).initialComment(text));
System.out.println("File sent: " + response2.isOk() + text);
} catch (IOException | SlackApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void sendMessageToChannel(String channel, String text, Optional<String> i
@Override
public void sendFileMessageToChannel(String channel, String fileBody, String fileName, String fileType, String text,
Optional<String> id) {
String caption = "";
String caption = text;
System.out.println("Send File to Telegram channel: " + channel);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ public static String replaceUmlaute(String orig) {
public IncomingMessage(String intent, String NluID, Boolean containsFile) {
if(intent != "") {
this.intentKeyword = replaceUmlaute(intent);
} else intent = "";
} else intentKeyword = "";
this.followupMessages = new HashMap<String, IncomingMessage>();
this.responses = new ArrayList<ChatResponse>();
this.containsFile = containsFile;
if (intentKeyword.equals("0") && containsFile){
intentKeyword = "anyFile";
}
if(NluID == ""){
this.NluID = "";
} else this.NluID = NluID;
Expand Down Expand Up @@ -69,7 +72,11 @@ public HashMap<String, IncomingMessage> getFollowingMessages() {
public void addFollowupMessage(String intentKeyword, IncomingMessage msg) {
String[] intentList = intentKeyword.split(",");
for (String intent : intentList) {
this.followupMessages.put(replaceUmlaute(intent).replaceAll("\\s+", ""), msg);
if (intent.equals("") && msg.containsFile){
this.followupMessages.put(replaceUmlaute(intent).replaceAll("\\s+", "") + "anyFile", msg);
} else {
this.followupMessages.put(replaceUmlaute(intent).replaceAll("\\s+", ""), msg);
}
}
// (this.followupMessages.put(replaceUmlaute(intentKeyword), msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@ public void setContextToBasic(String channel, String userid) {
}
} else {
// If only message to be sent
this.chatMediator.sendMessageToChannel(channel, state.getResponse(random).getResponse(),
Optional.of(userid));
String response = state.getResponse(random).getResponse();
if( response != null && !response.equals(""))
{
this.chatMediator.sendMessageToChannel(channel, response, Optional.of(userid));
}
if(state.getFollowingMessages().size()== 0){
this.stateMap.remove(channel);

}
}
} else {
}
Expand Down Expand Up @@ -295,9 +302,8 @@ public void handleMessages(ArrayList<MessageInfo> messageInfos, Bot bot) {
&& this.knownIntents.get(intent.getKeyword()).expectsFile()) {
state = this.knownIntents.get(intent.getKeyword());
// get("0") refers to an empty intent that is accessible from the start state
} else if (this.knownIntents.get("0") != null
&& this.knownIntents.get("0").expectsFile()) {
state = this.knownIntents.get("0");
} else if (this.knownIntents.get("anyFile") != null) {
state = this.knownIntents.get("anyFile");
} else {
state = this.knownIntents.get("default");
}
Expand All @@ -308,8 +314,12 @@ public void handleMessages(ArrayList<MessageInfo> messageInfos, Bot bot) {
// Incoming Message which expects file should not be chosen when no file was
// sent
if (state == null || state.expectsFile()) {
if(this.knownIntents.get("0") != null){
state = this.knownIntents.get("0");
} else{
state = this.knownIntents.get("default");
}
}
System.out.println(intent.getKeyword() + " detected with " + intent.getConfidence()
+ " confidence.");
stateMap.put(message.getChannel(), state);
Expand Down Expand Up @@ -359,17 +369,18 @@ public void handleMessages(ArrayList<MessageInfo> messageInfos, Bot bot) {
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
// In a conversation state, if no fitting intent was found and an empty leadsTo
// label is found
} else if (state.getFollowingMessages().get("") != null) {
System.out.println("Empty leadsTo1");
if (message.getFileBody() != null) {
if (state.getFollowingMessages().get("").expectsFile()) {
state = state.getFollowingMessages().get("");
} else if(state.getFollowingMessages().get("") != null || state.getFollowingMessages().get("anyFile") != null){
if (message.getFileBody() != null ) {
if (state.getFollowingMessages().get("anyFile") != null) {
state = state.getFollowingMessages().get("anyFile");
stateMap.put(message.getChannel(), state);
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
} else {
state = this.knownIntents.get("default");
}

} else {
if (!state.getFollowingMessages().get("").expectsFile()) {
if (state.getFollowingMessages().get("") != null) {
state = state.getFollowingMessages().get("");
stateMap.put(message.getChannel(), state);
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
Expand Down

0 comments on commit b0bc16f

Please sign in to comment.