2025-05-28 00:40:46 +02:00

45 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSteamSession = createSteamSession;
const steam_user_1 = __importDefault(require("steam-user"));
const globaloffensive_1 = __importDefault(require("globaloffensive"));
async function createSteamSession(username, password, mfa) {
const client = new steam_user_1.default();
const csgo = new globaloffensive_1.default(client);
const loginPromise = new Promise((resolve, reject) => {
client.logOn({
accountName: username,
password,
twoFactorCode: mfa,
});
client.once('loggedOn', () => {
console.log('✅ Eingeloggt bei Steam');
client.setPersona(steam_user_1.default.EPersonaState.Online);
client.gamesPlayed(730);
});
client.on('friendRelationship', (steamID, relationship) => {
if (relationship === steam_user_1.default.EFriendRelationship.RequestRecipient) {
console.log(` Freundschaftsanfrage von ${steamID.getSteamID64()} erhalten wird akzeptiert`);
client.addFriend(steamID, (err) => {
if (err) {
console.error(`❌ Fehler beim Akzeptieren von ${steamID.getSteamID64()}:`, err);
}
else {
console.log(`✅ Freund hinzugefügt: ${steamID.getSteamID64()}`);
}
});
}
});
csgo.once('connectedToGC', () => {
console.log('🎮 Verbunden mit dem Game Coordinator');
resolve();
});
client.once('error', reject);
});
await loginPromise;
return { client, csgo };
}