added live chat support both ways for mg
This commit is contained in:
parent
f1a846a044
commit
52c99a07f4
@ -8,6 +8,7 @@ const BOT_TOKEN = "";
|
||||
const API_URL = "";
|
||||
const CHANNEL_ID = "";
|
||||
const channel_livechat = "";
|
||||
const channel_livechat_mg = "";
|
||||
const channel_rcon_ze = "";
|
||||
const channel_adminchat_ze = "";
|
||||
|
||||
@ -209,6 +210,11 @@ const remotecon_css_ze = rcon({
|
||||
password: ''
|
||||
});
|
||||
|
||||
const remotecon_css_mg = rcon({
|
||||
address: '',
|
||||
password: ''
|
||||
});
|
||||
|
||||
String.prototype.formatUnicorn = String.prototype.formatUnicorn ||
|
||||
function () {
|
||||
"use strict";
|
||||
@ -272,16 +278,25 @@ async function checkNewMessages(channel_selected, admin_chat_bool) {
|
||||
const username = author.username || "Unknown";
|
||||
|
||||
//console.log(`[New] ${username}: ${content}`);
|
||||
await remotecon_css_ze.connect();
|
||||
if (admin_chat_bool)
|
||||
if (channel_selected == channel_livechat)
|
||||
{
|
||||
await remotecon_css_ze.command('sm_printtoadminchat_stoat "{0}" "{1}"'.formatUnicorn(username, content));
|
||||
await remotecon_css_ze.connect();
|
||||
if (admin_chat_bool)
|
||||
{
|
||||
await remotecon_css_ze.command('sm_printtoadminchat_stoat "{0}" "{1}"'.formatUnicorn(username, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
await remotecon_css_ze.command('sm_printtoallchat_stoat "{0}" "{1}"'.formatUnicorn(username, content));
|
||||
}
|
||||
await remotecon_css_ze.disconnect();
|
||||
}
|
||||
else
|
||||
else if (channel_selected == channel_livechat_mg)
|
||||
{
|
||||
await remotecon_css_ze.command('sm_printtoallchat_stoat "{0}" "{1}"'.formatUnicorn(username, content));
|
||||
await remotecon_css_mg.connect();
|
||||
await remotecon_css_mg.command('sm_printtoallchat_stoat "{0}" "{1}"'.formatUnicorn(username, content));
|
||||
await remotecon_css_mg.disconnect();
|
||||
}
|
||||
await remotecon_css_ze.disconnect();
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@ -349,7 +364,6 @@ async function checkNewMessages_rcon_ze() {
|
||||
remotecon_css_ze.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
lastProcessedMessageId_rcon_ze = message._id;
|
||||
} catch (error) {
|
||||
console.error('Error checking messages:', error.message);
|
||||
@ -364,6 +378,7 @@ async function start() {
|
||||
setInterval(updateServerStats, 300000);
|
||||
// Check for new messages 5 every second
|
||||
setInterval(() => checkNewMessages(channel_livechat, false), 5000);
|
||||
setInterval(() => checkNewMessages(channel_livechat_mg, false), 5000);
|
||||
setInterval(() => checkNewMessages(channel_adminchat_ze, true), 5000);
|
||||
|
||||
// Check rcon ze channel for new messages every 5 seconds
|
||||
@ -372,6 +387,7 @@ async function start() {
|
||||
// Initial update
|
||||
updateServerStats();
|
||||
checkNewMessages(channel_livechat, false);
|
||||
checkNewMessages(channel_livechat_mg, false);
|
||||
checkNewMessages(channel_adminchat_ze, true);
|
||||
checkNewMessages_rcon_ze();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user