adding ingame chat support from sourcemod through java to python

This commit is contained in:
jenzur
2020-05-05 23:52:01 +02:00
parent bc29b5b97d
commit d13e8cde77
4 changed files with 93 additions and 1 deletions
@@ -0,0 +1,42 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DataLayer;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.dbcp2.BasicDataSource;
import DataLayer.settings;
/**
*
* @author install1
*/
public class DBCPDataSourceAutismo {
private static BasicDataSource ds = new BasicDataSource();
static {
try {
ds.setDriver(new com.mysql.cj.jdbc.Driver());
ds.setUrl(settings.autismo_url);
ds.setUsername(settings.autismo_username);
ds.setPassword(settings.autismo_password);
ds.setMaxTotal(-1);
ds.setMinIdle(5);
ds.setMaxIdle(-1);
ds.setMaxOpenPreparedStatements(100);
} catch (SQLException ex) {
Logger.getLogger(DBCPDataSourceAutismo.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static Connection getConnection() throws SQLException {
return ds.getConnection();
}
private DBCPDataSourceAutismo() {
}
}
@@ -105,6 +105,34 @@ public class DataMapper {
return hlStatsMessages;
}
public static String check_autismo_mysql() {
String target = "";
try (Connection l_cCon = DBCPDataSourceAutismo.getConnection()) {
String l_sSQL = "SELECT chatmessage FROM unloze_css_autism_bot.chatting c WHERE c.responsemessage = '' LIMIT 1";
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL)) {
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
while (l_rsSearch.next()) {
target = l_rsSearch.getString(1);
}
}
}
} catch (SQLException ex) {
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
}
return target;
}
public static void update_autismo_mysql(String responseMsg, String update_string) {
try (Connection l_cCon = DBCPDataSourceAutismo.getConnection()) {
String l_sSQL = "UPDATE unloze_css_autism_bot.`chatting` SET `responsemessage` = '" + responseMsg + "' WHERE `chatmessage` = '" + update_string + "'";
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL)) {
l_pStatement.execute();
}
} catch (SQLException ex) {
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void CloseConnections(PreparedStatement ps, ResultSet rs, Connection con) {
if (rs != null) {
try {