This bot accept all trades but it need to accept only trade offers which contains [type: 'Consumer Grade SMG',] item in itemsToReceive. I was trying to do something like: If itemsToReceive contains Consumer Grade SMG then accpet offer else cancel offer but i failed. Im newby and i dont have any idea how to do that.
Sorry for my bad english.
My output console:
New offer #644673626 from [U:1:205839253]
[ { appid: 730,
contextid: { low: 2, high: 0, unsigned: true },
assetid: '3142560367',
classid: '310777708',
instanceid: '302028390',
amount: 1,
missing: true,
id: '3142560367',
icon_url: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHL
bXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpopuP1FBRw7ODYYzxb08-3moS0m_7zO6-fxzNQ65J03L2Vo
9-sigzj_kU6Mmr6LIKVdwNvZVHTqVTqxri8jZS4tYOJlyVoTeLjug',
icon_url_large: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4o
FJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpopuP1FBRw7ODYYzxb08-3moS0m_7zO6_ummpD78A
_27HA9tvw3gDg_UBlMWH0IYDDIwU3aVzQ_1Tvxefs1pPou8uawXBnsz5iuyjoOPjz8g',
icon_drag_url: '',
name: 'P90 | Sand Spray',
market_hash_name: 'P90 | Sand Spray (Minimal Wear)',
market_name: 'P90 | Sand Spray (Minimal Wear)',
name_color: 'D2D2D2',
background_color: '',
type: 'Consumer Grade SMG',
tradable: true,
marketable: true,
commodity: false,
market_tradable_restriction: 7,
fraudwarnings: '',
descriptions:
{ '0': [Object],
'1': [Object],
'2': [Object],
'3': [Object],
'4': [Object],
'5': [Object] },
owner_descriptions: '',
actions: { '0': [Object] },
market_actions: { '0': [Object] },
tags:
{ '0': [Object],
'1': [Object],
'2': [Object],
'3': [Object],
'4': [Object],
'5': [Object] } } ]
Offer accepted
Offer #644673626 changed: Active -Accepted
Received: P90 | Sand Spray
And bot code:
/**
* STOREHOUSE - node-steam
*
* Uses node-steam-user for notifications and accepts all incoming trade offers
*/
var SteamUser = require('steam-user');
var TradeOfferManager = require('../lib/index.js'); // use require('steam-tradeoffer-manager') in production
var fs = require('fs');
var client = new SteamUser();
var manager = new TradeOfferManager({
"steam": client, // Polling every 30 seconds is fine since we get notifications from Steam
"domain": "example.com", // Our domain is example.com
"language": "en" // We want English item descriptions
});
// Steam logon options
var logOnOptions = {
"accountName": "xxxxx",
"password": "xxxxx"
};
if(fs.existsSync('polldata.json')) {
manager.pollData = JSON.parse(fs.readFileSync('polldata.json'));
}
client.logOn(logOnOptions);
client.on('loggedOn', function() {
console.log("Logged into Steam");
});
client.on('webSession', function(sessionID, cookies) {
manager.setCookies(cookies, function(err) {
if(err) {
console.log(err);
process.exit(1); // Fatal error since we couldn't get our API key
return;
}
console.log("Got API key: " + manager.apiKey);
});
});
manager.on('newOffer', function(offer) {
console.log("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID());
console.log(offer.itemsToReceive);
offer.accept(function(err) {
if(err) {
console.log("Unable to accept offer: " + err.message);
} else {
console.log("Offer accepted");
}
});
});
manager.on('receivedOfferChanged', function(offer, oldState) {
console.log("Offer #" + offer.id + " changed: " + TradeOfferManager.getStateName(oldState) + " -> " + TradeOfferManager.getStateName(offer.state));
if(offer.state == TradeOfferManager.ETradeOfferState.Accepted) {
offer.getReceivedItems(function(err, items) {
if(err) {
console.log("Couldn't get received items: " + err);
} else {
var names = items.map(function(item) {
return item.name;
});
console.log("Received: " + names.join(', '));
}
});
}
});
manager.on('pollData', function(pollData) {
fs.writeFile('polldata.json', JSON.stringify(pollData));
});
Have try.
manager.on('newOffer', function(offer) {
console.log("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID());
console.log(offer.itemsToReceive);
for(var i = 0; i > offer.itemsToReceive.length)
{
if(offer.itemsToReceive[i]['type'] != "Consumer Grade SMG")
{
return;
if(i == offer.itemsToReceive.length)
{
offer.accept(function(err){
if(err){
console.log("Unable to accept offer: " + err.message);
}
else{
console.log("Offer accepted");
}
});
}
}
}
});
Related
I'm trying to save a blob as name.ics, but for some reason on iPhone they all get saved as name.ics.txt
This is the code
// Creating event template for ICS file
const event = {
start: startAt,
end: endAt,
title: !location ? "Appointment " + appointment.appointmentType + " " + appointment.sessionName : "Appointment",
description: "Your Practitionier: " + appointment.practitionerName,
location: !location ? appointment.locationName + ", " + addressString + ", " + postalCode : location,
status: "CONFIRMED",
alarms: [
{
action: "display",
description: "Appointment",
trigger: { hours: reminder.hours, minutes: reminder.minutes, before: true },
},
],
};
// Event handlers
const handleSave = () => {
createEvent(event, (error, value) => {
const blob = new Blob([value], { type: "text/plain;charset=utf-8" });
saveAs(blob, "event-schedule.ics");
});
};
I don't know what's wrong with my code am not getting the intended output. Anybody to lend a helping hand and I'll really appreciate it.
If append the row class inside the for loop am getting all the messages but you can't differentiate who sent and who received and when I append the class outside the for loop am only getting one message.
xhr.onload = function () {
var messages = [
{ id: 36, message: "hay here", username: null, senderId: 1, receiverId: 9 },
{ id: 38, message: "hay there again", username: null, senderId: 1, receiverId: 9 },
{ id: 37, message: "yes hay", username: null, senderId: 9, receiverId: 1 },
];
var rowClass = "";
for (var message = 0; message < messages.length; message++) {
if (messages[message].senderId === messages[message].senderId) {
rowClass =
'<div style="text-align:right">' +
'<p style="background-color:lightblue">' +
mymessages[message].message +
"</p>" +
"<div>";
} else {
rowClass =
'<div style="text-align:left">' + '<p style="background-color:green">';
messages[message].message;
"</p>" + "<div>";
}
}
$(".message").append(rowClass);
};
You need to check whether the current user's id is same as that of the message, for example:
const currentUserId = 9;
var messages = [
{ id: 36, message: "hay here", username: null, senderId: 1, receiverId: 9 },
{ id: 38, message: "hay there again", username: null, senderId: 1, receiverId: 9 },
{ id: 37, message: "yes hay", username: null, senderId: 9, receiverId: 1 },
];
var rowClass = "";
for (var message = 0; message < messages.length; message++) {
if (messages[message].senderId === currentUserId) {
rowClass +=
'<div style="text-align:right">' +
'<p style="background-color:lightblue">' +
messages[message].message +
"</p>" +
"<div>";
} else {
rowClass +=
'<div style="text-align:left">' +
'<p style="background-color:green">' +
messages[message].message +
"</p>" +
"<div>";
}
}
$(".message").append(rowClass);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="message"></div>
I am trying to store some data from the 'app_remove' event in the database.
It works for the standard information like appInfo.appInstanceId.
But how do I get the userProperty values, since they are objects?
exports.appremoved = functions.analytics.event('app_remove').onLog(event => {
console.log(event.data);
console.log(event.data.user.Selected_Games);
const user = event.data.user;
if (user != null) {
if(user.userId != null){
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "deviceId").set(user.userId);
}
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "app_remove").set(event.data.logTime);
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "app_install").set(user.firstOpenTime);
}
});
This is the result of the console.log of event.data
AnalyticsEvent {
params: { firebase_conversion: 1, firebase_event_origin: 'auto' },
name: 'app_remove',
reportingDate: '20170719',
logTime: '2017-07-19T10:57:12.920Z',
user:
UserDimensions {
deviceInfo:
{ deviceCategory: 'mobile',
deviceModel: 'WAS-LX1A',
deviceTimeZoneOffsetSeconds: 7200,
platformVersion: '7.0',
userDefaultLanguage: 'it-it' },
geoInfo:
{ city: 'Milan',
continent: '039',
country: 'Italy',
region: 'Lombardy' },
appInfo:
{ appId: 'com.example.example',
appInstanceId: '000000',
appPlatform: 'ANDROID',
appStore: 'com.android.vending',
appVersion: '1.12' },
firstOpenTime: '2017-07-17T12:37:01.320Z',
userProperties:
{ Active_Notification: [Object],
Referrer: [Object],
Selected_Games: [Object],
Selected_Sources: [Object],
Selected_Topics: [Object],
first_open_time: [Object],
user_id: [Object] },
bundleInfo: ExportBundleInfo { bundleSequenceId: 10, serverTimestampOffset: 693 } } }
I found the solution.
I did a console.log of that object (event.data.user.Selected_Games)
UserPropertyValue { value: '4', setTime: '2017-06-27T01:22:25.375Z' }
So to get the value
event.data.user.userProperties.Selected_Games.value
how do i update item in dynamoDB using nodejs ?
here is the ITEM list from DynamoDB javascript shell -
"Items": [
{
"EmailId": "swa#acc.com",
"flag": 1,
"deviceOS": "IOS",
"companyName": "VCC",
"snsEndpoint": "00d0sadas",
"CreatedAt": 22112015,
"Otp": "ABCDEF",
},
i want to update flag value to 2 ... this is my code . what do i do?? what am i doing wrong ?? help is appreciated...
var params = {
TableName: 'users',
Key: {
id: {
'S': req.query.id
},
flag: {
'N': 2
}
},
UpdateExpression: 'SET #flag =:val1',
ExpressionAttributeNames: {
'#flag': 'flag' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': {
'N': 2
},
}
};
dynamodb.updateItem(params, function(err, data) {
if (err) {
console.log('Error :' + err);
} else {
//subscribe(bodydata.id);
console.log('EndpointArn Saved successful');
console.log('Data :' + JSON.stringify(data.flag));
}
});
You are trying to modify the flag: { 'N': 2 } which doesnot exist. But you wanted to modify the flag: { 'N': 1 } value to 2. So try doing like this:
var params = {
TableName: 'users',
Key: {
id: {
'S': req.query.id
},
flag: {
'N': 1
}
},
UpdateExpression: 'SET #flag =:val1',
ExpressionAttributeNames: {
'#flag': 'flag' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': {
'N': 2
},
}
};
dynamodb.updateItem(params, function(err, data) {
if (err) {
console.log('Error :' + err);
} else {
//subscribe(bodydata.id);
console.log('EndpointArn Saved successful');
console.log('Data :' + JSON.stringify(data.flag));
}
});
I have the following code in my /config/bootstrap.js that inserts some dummy data for development.
/* global User */
/* global Category */
var insertDummyUsers = function() {
sails.log.info('Inserting dummy users');
var users = [
{ email: 'test#test.com' },
{ email: 'test1#testdomain.gr' },
{ email: 'test2#cnn.com'}
];
return User.create(users);
};
var insertDummyCategories = function() {
sails.log.info('Inserting dummy categories');
var categories = [
{ name: 'Furniture' },
{ name: 'Lighting' },
{ name: 'Computers' },
{ name: 'Networking' },
{ name: 'Telecommunications' },
{ name: 'TV & Audio' }
];
return Category.create(categories);
};
module.exports.bootstrap = function(cb) {
User.count().then(function(err,count){
if (count > 0) {
cb();
} else {
// Insert some dummy users
insertDummyUsers()
.then(insertDummyCategories)
.then(cb);
}
});
};
When I lift the app I am getting:
info: Inserting dummy users
info: Inserting dummy categories
error: Bootstrap encountered an error: see(below)
error: [ { name: 'Networking, id: 4, createdAt: ..., updatedAt: ... }]
[... so on]
However I can see that the data is being persisted in the database but the app is not getting lifted.
What's going on here? It really gives no clue.
EDIT
migrate: is set to drop
The Category model is defined as follows:
module.exports = {
attributes: {
name: {
type: 'string'
},
/* Associations */
subcategories: {
collection: 'Subcategory',
via: 'parentCategory'
}
}
};
I find this really bizarre, when I edit your create function like below. It works even when the callback function is empty.
I'll have to look a bit more, but this could be a bug that needs to be reported.
return Category.create(categories, function(err, returnModel) {
sails.log.debug('This should work!!! -- Error : ' + err + 'model : ' +
returnModel); });