This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
example.js
48 lines (37 loc) · 1.54 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var util = require('util');
var ParentBot = require('../parentbot.js'); //change to 'steam-parentbot' if not running from examples directory
var Steam = ParentBot.Steam; // Steam object
var MySQL = require('mysql'); //require your own modules
var ChildBot = function () {
ChildBot.super_.apply(this, arguments);
}
util.inherits(ChildBot, ParentBot);
var Bot = new ChildBot('username', 'password', {
apikey: '1234567890987654321', //default apikey option for steam
guardCode: 'ABCDE', //put guardcode here, remove after successful login
sellPrice: '1 ref' //add your own options
});
ChildBot.prototype._onFriendMsg = function (steamID, message, type) { //overwrite default event handlers
if(type === Steam.EChatEntryType.ChatMsg) {
if(message === '!prices') {
this.logger.info(steamID + ' sent: ' + message);
Bot.steamFriends.sendMessage(steamID, 'Selling for ' + Bot.options.sellPrice); //use your custom options
}
}
else {
console.log(type);
}
}
Bot.steamTrading.on('tradeProposed', function (tradeID, steamID) { //create your own listeners
Bot.steamTrading.respondToTrade(tradeID, false);
Bot.logger.verbose('Trade request from ' + steamID);
});
Bot.connection = MySQL.createConnection({ //add properties to the bot from an external module
host: 'localhost',
user: 'root',
password: 'password'
});
Bot.connection.connect(function (e) { //call methods on your new property
if (e) Bot.logger.error('Error connecting to MySQL: ' + e)
});
Bot.connect(); //connect to Steam