Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const SteamUser = require('steam-user');
- const SteamTotp = require('steam-totp')
- const config = require ('./config.json')
- const SteamCommunity = require('steamcommunity')
- const TradeOfferManager = require('steam-tradeoffer-manager')
- const Winston = require('winston')
- const client = new SteamUser();
- const community = new SteamCommunity();
- const manager = new TradeOfferManager({
- });
- //Auto Login and auth
- const logOnOptions = {
- accountName: config.username,
- password: config.password,
- twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
- };
- SteamCommunity.ChatState = 3;
- client.logOn(logOnOptions);
- client.on('loggedOn', () => {
- console.log('Successfully logged on');
- client.setPersona(SteamUser.Steam.EPersonaState.Online);
- client.gamesPlayed(["Nycklar | Bio För Pris | Inne"]);
- });
- client.on("friend.Message", function(steamID, message) {
- if (message == "Tja"){
- client.chatMessage(steamID, "Tja");
- }
- });
- client.on('webSession', (sessionid, cookies) => {
- manager.setCookies(cookies);
- community.setCookies(cookies);
- community.startConfirmationChecker(20000, config.identitysecret);
- });
- //Some trade stuff
- function acceptOffer(offer) {
- offer.accept((err) => {
- community.checkConfirmations();
- console.log("We accepted an offer")
- if (err) console.log ("There was an error accepting the offer.")
- });
- }
- function declineOffer(offer) {
- offer.decline((err) => {
- console.log("We declined an offer.")
- if (err) console.log ("There was an error declining the offer.")
- });
- }
- manager.on('newOffer', (offer) => {
- if (offer.partner.getSteamID64() === config.ownerID) {
- acceptOffer(offer);
- }
- };
- //Auto friend req accept etc
- client.friends.on('relationships', function(){
- var friendcount = 0;
- for (steamID in client.friends.friends) {
- friendcount++;
- if (client.friends.friends[steamID] === SteamUser.Steam.EFriendRelationship.RequestRecipient) {
- logger.info("Friend request while offline from: "+steamID);
- client.friends.addFriend(steamID);
- }
- }
- logger.debug("We have "+friendcount+" friends.");
- if (friendcount > 200) {
- logger.warn("We're approaching the default friends limit.");
- }
- });
- client.friends.on('friend', function (steamID, realationship) {
- if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipent) {
- logger.info('[' + steamID + '] Accepted friend request');
- client.friends.addFriend(steamID);
- }
- else if (relationship == SteamUser.Steam.EFriendRelationship.None) {
- logger.info('[' + steamID + '] Un-friended');
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement