From c0b43d422b1fccbd95612abc6e8145f1cc650b48 Mon Sep 17 00:00:00 2001 From: DentFuse Date: Sun, 18 Mar 2018 18:11:17 +0530 Subject: [PATCH 01/27] Added a chapter teaching how to handle steam messages --- .../README.md | 63 +++++++++++++++++++ .../config.json | 5 ++ .../project4.js | 36 +++++++++++ Chapter 3 - User Interaction/README.md | 9 +-- README.md | 1 + 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md new file mode 100644 index 0000000..68e9975 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md @@ -0,0 +1,63 @@ +# Chatting With Friends + +So we have added friends, now let's talk to them ! The `steam-user` module +emits an event `friendMessage` whenever a friend messages us. We will use it +as follows : + +```js +client.on('friendMessage', (steamid, message) => { + // A friend with `steamid` has sent us a chat message saying `message` +}); +``` + +This also emits two parameters along with the event: the user's `steamid`, +and the message the user has sent us. + +Now let's reply to our friend when he sends us a message : + +```js +client.on('friendMessage', (steamid, message) => { + client.chatMessage(steamid,"Hello There !"); +}); +``` + +Now we have added a listener for the `friendMessage` event. Also we now +reply to any user who sends us a message, regardless of his message. We use the +`.chatMessage` method we learnt about before to send the reply. + +Great ! Now the bot talks to us ! Now let's try to teach the bot some specific +replies or commands. + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } +}); +``` + +Now we have added a `if` condition that checks if the reply is what we expect. +The bot will now reply with a warm `Hello There !` whenever a user sends a +message saying `Hello`. But the bot won't reply when the expected message +not sent, so to deal with that we add a `else` condition. + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); +``` + +Now the bot will be reply saying `I failed to understand you :/` whenever an +user sends us an unexpected message. Now try adding some of your own `else if` +conditions. A working example of this has been added to the final code. + +For the final working code, check out project4.js. + +This is it for this chapter! See ya in the next one! + +This chapter was written by [@DentFuse](https://github.com/DentFuse) for +[andrewda/node-steam-guide](https://github.com/DentFuse/node-steam-guide/). diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json new file mode 100644 index 0000000..2fe64e4 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json @@ -0,0 +1,5 @@ +{ + "username": "", + "password": "", + "sharedSecret": "" +} diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js new file mode 100644 index 0000000..0fd856e --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js @@ -0,0 +1,36 @@ +const SteamUser = require('steam-user'); +const SteamTotp = require('steam-totp'); +const config = require('./config.json'); + +const client = new SteamUser(); + +const logOnOptions = { + accountName: config.username, + password: config.password, + twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret) +}; + +client.logOn(logOnOptions); + +client.on('loggedOn', () => { + console.log('Logged into Steam'); + + client.setPersona(SteamUser.Steam.EPersonaState.Online); + client.gamesPlayed(440); +}); + +client.on('friendRelationship', (steamid, relationship) => { + if (relationship === 2) { + client.addFriend(steamid); + client.chatMessage(steamid, 'Hello there! Thanks for adding me!'); + } +}); +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else if (message === "Hey") { + client.chatMessage(steamid,"Hey There !") + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); diff --git a/Chapter 3 - User Interaction/README.md b/Chapter 3 - User Interaction/README.md index 5f673f3..fa1af61 100644 --- a/Chapter 3 - User Interaction/README.md +++ b/Chapter 3 - User Interaction/README.md @@ -3,14 +3,15 @@ ## Table of Contents - [Chapter 3.1 - Friend Requests](./Chapter%203.1%20-%20Friend%20Requests) +- [Chapter 3.2 - Chatting With Friends](./Chapter%203.2%20-%20Chatting%20With%20Friends) ## Summary In this chapter, you will learn how to interact with users by sending friend -requests, handling requests, sending messages, and dealing with various other -interactions. +requests, handling requests, receiving and sending messages, and dealing with +various other interactions. ## Authors -This chapter was written by [@andrewda](https://github.com/andrewda) and -[@Arze1](https://github.com/Arze1). +This chapter was written by [@andrewda](https://github.com/andrewda), +[@Arze1](https://github.com/Arze1) and [@DentFuse](https://github.com/DentFuse). diff --git a/README.md b/README.md index dc9169e..47c5150 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ A complete guide to building Steam bots using Node.js. - [Chapter 2.4 - Accepting Donations](./Chapter%202%20-%20Trading/Chapter%202.4%20-%20Accepting%20Donations) - [Chapter 3 - User Interaction](./Chapter%203%20-%20User%20Interaction) - [Chapter 3.1 - Friend Requests](./Chapter%203%20-%20User%20Interaction/Chapter%203.1%20-%20Friend%20Requests) + - [Chapter 3.2 - Chatting With Friends](./Chapter%203%20-%20User%20Interaction/Chapter%203.2%20-%20Chatting%20With%20Friends) - [Chapter 4 - Basics of Web Development](./Chapter%204%20-%20Basics%20of%20Web%20Development) - [Chapter 4.1 - Prerequisites](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.1%20-%20Prerequisites) - [Chapter 4.2 - Base App](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.2%20-%20Base%20App) From 5f3ee7f3193b39dff3117ccee22fb287e6f34c00 Mon Sep 17 00:00:00 2001 From: Shivam Dwivedi Date: Wed, 21 Mar 2018 21:25:16 +0530 Subject: [PATCH 02/27] Added missing ";" --- .../Chapter 3.2 - Chatting With Friends/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md index 68e9975..33eba16 100644 --- a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md @@ -46,7 +46,7 @@ client.on('friendMessage', (steamid, message) => { if (message === "Hello") { client.chatMessage(steamid,"Hello There !"); } else { - client.chatMessage(steamid,"I failed to understand you :/") + client.chatMessage(steamid,"I failed to understand you :/"); } }); ``` From d6717e219991acbee2c69ce220d9b4174d96cfcd Mon Sep 17 00:00:00 2001 From: Shivam Dwivedi Date: Wed, 21 Mar 2018 21:29:15 +0530 Subject: [PATCH 03/27] Added ';' in project4.js --- .../Chapter 3.2 - Chatting With Friends/project4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js index 0fd856e..213db33 100644 --- a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js @@ -29,8 +29,8 @@ client.on('friendMessage', (steamid, message) => { if (message === "Hello") { client.chatMessage(steamid,"Hello There !"); } else if (message === "Hey") { - client.chatMessage(steamid,"Hey There !") + client.chatMessage(steamid,"Hey There !"); } else { - client.chatMessage(steamid,"I failed to understand you :/") + client.chatMessage(steamid,"I failed to understand you :/"); } }); From 771912872a5bc3acba154c83b7379646938348ce Mon Sep 17 00:00:00 2001 From: Andrew Dassonville Date: Wed, 21 Mar 2018 09:07:13 -0700 Subject: [PATCH 04/27] Update README.md --- .../README.md | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md index 33eba16..ab4730b 100644 --- a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md @@ -1,8 +1,8 @@ # Chatting With Friends -So we have added friends, now let's talk to them ! The `steam-user` module +So we have added friends, now let's talk to them! The `steam-user` module emits an event `friendMessage` whenever a friend messages us. We will use it -as follows : +as follows: ```js client.on('friendMessage', (steamid, message) => { @@ -13,11 +13,11 @@ client.on('friendMessage', (steamid, message) => { This also emits two parameters along with the event: the user's `steamid`, and the message the user has sent us. -Now let's reply to our friend when he sends us a message : +Now let's reply to our friend when he sends us a message: ```js client.on('friendMessage', (steamid, message) => { - client.chatMessage(steamid,"Hello There !"); + client.chatMessage(steamid, "Hello There!"); }); ``` @@ -25,39 +25,37 @@ Now we have added a listener for the `friendMessage` event. Also we now reply to any user who sends us a message, regardless of his message. We use the `.chatMessage` method we learnt about before to send the reply. -Great ! Now the bot talks to us ! Now let's try to teach the bot some specific +Great! Now the bot talks to us! Now let's try to teach the bot some specific replies or commands. ```js client.on('friendMessage', (steamid, message) => { if (message === "Hello") { - client.chatMessage(steamid,"Hello There !"); + client.chatMessage(steamid, "Hello There!"); } }); ``` Now we have added a `if` condition that checks if the reply is what we expect. -The bot will now reply with a warm `Hello There !` whenever a user sends a +The bot will now reply with a warm `Hello There!` whenever a user sends a message saying `Hello`. But the bot won't reply when the expected message not sent, so to deal with that we add a `else` condition. ```js client.on('friendMessage', (steamid, message) => { if (message === "Hello") { - client.chatMessage(steamid,"Hello There !"); + client.chatMessage(steamid, "Hello There!"); } else { - client.chatMessage(steamid,"I failed to understand you :/"); + client.chatMessage(steamid, "I failed to understand you :/"); } }); ``` -Now the bot will be reply saying `I failed to understand you :/` whenever an +Now the bot will be reply saying `I failed to understand you :/` whenever a user sends us an unexpected message. Now try adding some of your own `else if` conditions. A working example of this has been added to the final code. For the final working code, check out project4.js. -This is it for this chapter! See ya in the next one! - This chapter was written by [@DentFuse](https://github.com/DentFuse) for [andrewda/node-steam-guide](https://github.com/DentFuse/node-steam-guide/). From a52e77cbcb2745d23eaf78f0ef4cd9c6adff68fc Mon Sep 17 00:00:00 2001 From: DentFuse Date: Mon, 23 Apr 2018 19:59:26 +0530 Subject: [PATCH 05/27] Added chapter 3.2 --- .../README.md | 63 +++++++++++++++++++ .../config.json | 5 ++ .../project4.js | 36 +++++++++++ Chapter 3 - User Interaction/README.md | 9 +-- README.md | 1 + 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json create mode 100644 Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md new file mode 100644 index 0000000..68e9975 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md @@ -0,0 +1,63 @@ +# Chatting With Friends + +So we have added friends, now let's talk to them ! The `steam-user` module +emits an event `friendMessage` whenever a friend messages us. We will use it +as follows : + +```js +client.on('friendMessage', (steamid, message) => { + // A friend with `steamid` has sent us a chat message saying `message` +}); +``` + +This also emits two parameters along with the event: the user's `steamid`, +and the message the user has sent us. + +Now let's reply to our friend when he sends us a message : + +```js +client.on('friendMessage', (steamid, message) => { + client.chatMessage(steamid,"Hello There !"); +}); +``` + +Now we have added a listener for the `friendMessage` event. Also we now +reply to any user who sends us a message, regardless of his message. We use the +`.chatMessage` method we learnt about before to send the reply. + +Great ! Now the bot talks to us ! Now let's try to teach the bot some specific +replies or commands. + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } +}); +``` + +Now we have added a `if` condition that checks if the reply is what we expect. +The bot will now reply with a warm `Hello There !` whenever a user sends a +message saying `Hello`. But the bot won't reply when the expected message +not sent, so to deal with that we add a `else` condition. + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); +``` + +Now the bot will be reply saying `I failed to understand you :/` whenever an +user sends us an unexpected message. Now try adding some of your own `else if` +conditions. A working example of this has been added to the final code. + +For the final working code, check out project4.js. + +This is it for this chapter! See ya in the next one! + +This chapter was written by [@DentFuse](https://github.com/DentFuse) for +[andrewda/node-steam-guide](https://github.com/DentFuse/node-steam-guide/). diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json new file mode 100644 index 0000000..2fe64e4 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/config.json @@ -0,0 +1,5 @@ +{ + "username": "", + "password": "", + "sharedSecret": "" +} diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js new file mode 100644 index 0000000..0fd856e --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/project4.js @@ -0,0 +1,36 @@ +const SteamUser = require('steam-user'); +const SteamTotp = require('steam-totp'); +const config = require('./config.json'); + +const client = new SteamUser(); + +const logOnOptions = { + accountName: config.username, + password: config.password, + twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret) +}; + +client.logOn(logOnOptions); + +client.on('loggedOn', () => { + console.log('Logged into Steam'); + + client.setPersona(SteamUser.Steam.EPersonaState.Online); + client.gamesPlayed(440); +}); + +client.on('friendRelationship', (steamid, relationship) => { + if (relationship === 2) { + client.addFriend(steamid); + client.chatMessage(steamid, 'Hello there! Thanks for adding me!'); + } +}); +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else if (message === "Hey") { + client.chatMessage(steamid,"Hey There !") + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); diff --git a/Chapter 3 - User Interaction/README.md b/Chapter 3 - User Interaction/README.md index 5f673f3..fa1af61 100644 --- a/Chapter 3 - User Interaction/README.md +++ b/Chapter 3 - User Interaction/README.md @@ -3,14 +3,15 @@ ## Table of Contents - [Chapter 3.1 - Friend Requests](./Chapter%203.1%20-%20Friend%20Requests) +- [Chapter 3.2 - Chatting With Friends](./Chapter%203.2%20-%20Chatting%20With%20Friends) ## Summary In this chapter, you will learn how to interact with users by sending friend -requests, handling requests, sending messages, and dealing with various other -interactions. +requests, handling requests, receiving and sending messages, and dealing with +various other interactions. ## Authors -This chapter was written by [@andrewda](https://github.com/andrewda) and -[@Arze1](https://github.com/Arze1). +This chapter was written by [@andrewda](https://github.com/andrewda), +[@Arze1](https://github.com/Arze1) and [@DentFuse](https://github.com/DentFuse). diff --git a/README.md b/README.md index dc9169e..8ae0a39 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ A complete guide to building Steam bots using Node.js. - [Chapter 2.4 - Accepting Donations](./Chapter%202%20-%20Trading/Chapter%202.4%20-%20Accepting%20Donations) - [Chapter 3 - User Interaction](./Chapter%203%20-%20User%20Interaction) - [Chapter 3.1 - Friend Requests](./Chapter%203%20-%20User%20Interaction/Chapter%203.1%20-%20Friend%20Requests) + - [Chapter 3.2 - Chatting With Friends](./Chapter%203%20-%20User%20Interaction/Chapter%203.2%20-%20Chatting%20With%20Friends) - [Chapter 4 - Basics of Web Development](./Chapter%204%20-%20Basics%20of%20Web%20Development) - [Chapter 4.1 - Prerequisites](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.1%20-%20Prerequisites) - [Chapter 4.2 - Base App](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.2%20-%20Base%20App) From c485af798dadb2d7709ab9c243ca78c4f76a309d Mon Sep 17 00:00:00 2001 From: Shivam Dwivedi Date: Mon, 23 Apr 2018 20:11:54 +0530 Subject: [PATCH 06/27] CleanUp --- .../Chapter 3.2 - Chatting With Friends/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md index 68e9975..07a9e41 100644 --- a/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md +++ b/Chapter 3 - User Interaction/Chapter 3.2 - Chatting With Friends/README.md @@ -55,9 +55,10 @@ Now the bot will be reply saying `I failed to understand you :/` whenever an user sends us an unexpected message. Now try adding some of your own `else if` conditions. A working example of this has been added to the final code. -For the final working code, check out project4.js. +For the final working code, check out project4.js. Please do try adding an +`else if` condition yourself before seeing the final code, practising on your +own self is better than copy-pasting. -This is it for this chapter! See ya in the next one! This chapter was written by [@DentFuse](https://github.com/DentFuse) for -[andrewda/node-steam-guide](https://github.com/DentFuse/node-steam-guide/). +[Steam-Bot-Basics/node-steam-guide](https://github.com/Steam-Bot-Basics/node-steam-guide). From 5a49a12246e1c13d83d0574ad4a5a78fbd00fc17 Mon Sep 17 00:00:00 2001 From: David your friend Date: Thu, 26 Apr 2018 02:31:54 -0700 Subject: [PATCH 07/27] Update README.md - Removed donation links - Updated Codacy links --- README.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/README.md b/README.md index 8ae0a39..c8f654d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Andrew's Guide to Steam Bots [![Codacy][codacy-img]][codacy-url] -[![PayPal][paypal-img]][paypal-url] -[![Steam Donate][steam-img]][steam-url] [![Creative Commons][cc-img]][cc-url] @@ -71,21 +69,11 @@ http://cs.money/. Please read the [contribution guidelines](/CONTRIBUTING.md) before creating a Pull Request. -## Donating -If you found this guide useful, there are a few ways for you to support me and -keep this project going: - -- [Steam](https://steamcommunity.com/tradeoffer/new/?partner=132224795&token=HuEE9Mk1) -- [Patreon](https://www.patreon.com/andrewda) [codacy-img]: https://img.shields.io/codacy/grade/5822ba91cc994725932f71ee6b926400.svg?style=flat-square -[codacy-url]: https://www.codacy.com/app/andrewda/node-steam-guide -[paypal-img]: https://img.shields.io/badge/donate-PayPal-blue.svg?style=flat-square -[paypal-url]: https://www.paypal.me/andrewda/5 -[steam-img]: https://img.shields.io/badge/donate-Steam-lightgrey.svg?style=flat-square -[steam-url]: https://steamcommunity.com/tradeoffer/new/?partner=132224795&token=HuEE9Mk1 +[codacy-url]: https://app.codacy.com/app/Steam-Bot-Basics/node-steam-guide_2 [cc-img]: https://i.creativecommons.org/l/by/4.0/88x31.png [cc-url]: https://creativecommons.org/licenses/by/4.0/ From dc9a1d38c7bde8b87ddd0fde11abd63ea2f60a02 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 26 Apr 2018 02:55:00 -0700 Subject: [PATCH 08/27] Update README.md fixed Codacy link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8f654d..e54aee4 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,6 @@ a Pull Request. [codacy-img]: https://img.shields.io/codacy/grade/5822ba91cc994725932f71ee6b926400.svg?style=flat-square -[codacy-url]: https://app.codacy.com/app/Steam-Bot-Basics/node-steam-guide_2 +[codacy-url]: https://app.codacy.com/app/Steam-Bot-Basics/node-steam-guide/dashboard [cc-img]: https://i.creativecommons.org/l/by/4.0/88x31.png [cc-url]: https://creativecommons.org/licenses/by/4.0/ From 26ee89c2062c4ed411567ab1a14480bd86a85c85 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 26 Apr 2018 08:06:29 -0700 Subject: [PATCH 09/27] Update Chapter 1.1 README.md edit by @Burn1ngBr1ght --- .../Chapter 1.1 - Introduction/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md index 2d4fa82..3376b1a 100644 --- a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md +++ b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md @@ -1,13 +1,13 @@ # Chapter 1.1 - Introduction -Steam bots can be used for many things, ranging from chat bots to item exchange -websites. Every Steam website you've ever used that takes items or sends you -items uses some form of Steam bot, be it scrap.tf, csgojackpot.com, or so many -more. Throughout this course, we'll learn how to create everything from chat -bots to fully-functioning trade/exchange websites using a series of -mini-projects. +Steam bots can be used for many things: + - Donation Bots + - Chat bots + - Trade bots (in steam or connected to a website) + +Websites like scrap.tf, cs.money or csgojackpot.com all use some sort of steam bot -Without further adieu, let's jump right into the basics of programming Steam -bots in the next section. +In this course, you will learn how to create everything from chat +bots to fully-functioning trade websites. [Continue Reading](../Chapter%201.2%20-%20Prerequisites) From 7e8ac48a8abe76d3b6686906b473ac76407330d1 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 26 Apr 2018 08:29:12 -0700 Subject: [PATCH 10/27] Set theme jekyll-theme-tactile --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..259a24e --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-tactile \ No newline at end of file From ce214482d52d73eab1937b8bbafa7ada996199b8 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 26 Apr 2018 08:32:46 -0700 Subject: [PATCH 11/27] Set theme jekyll-theme-cayman --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 259a24e..c419263 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-tactile \ No newline at end of file +theme: jekyll-theme-cayman \ No newline at end of file From 0c0779e5b106f4275bc8b5c02d11f680cd092169 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 26 Apr 2018 08:33:30 -0700 Subject: [PATCH 12/27] Set theme jekyll-theme-cayman From 2c151ccaed086d33ac5e6348a29a6f50a0297f72 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Wed, 9 May 2018 05:50:21 -0700 Subject: [PATCH 13/27] Updated README.md - Chapter 6.1 --- .../Chapter 6.1 - Prerequisites/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md b/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md index ffad5b5..6054a50 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md @@ -4,5 +4,6 @@ The dependencies we need for this chapter: - [`passport.socketio`](https://www.npmjs.com/package/passport.socketio) - [`connect-mongo`](https://www.npmjs.com/package/connect-mongo) +- Install [`MongoDB`](https://docs.mongodb.com/manual/installation) CLI [Continue Reading](../Chapter%206.2%20-%20Getting%20Started) From a137787973b09371af05bd7a70a872a57bdc8205 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Tue, 5 Jun 2018 11:41:19 -0700 Subject: [PATCH 14/27] Update README.md --- .../Chapter 1.1 - Introduction/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md index 3376b1a..82f7331 100644 --- a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md +++ b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md @@ -1,11 +1,11 @@ # Chapter 1.1 - Introduction -Steam bots can be used for many things: - - Donation Bots - - Chat bots - - Trade bots (in steam or connected to a website) +Steam bots can perform many functions: + - Accept donations, + - Chat with individuals or in group chats, + - Send, accept/decline, and confirm trades (automated). -Websites like scrap.tf, cs.money or csgojackpot.com all use some sort of steam bot +Websites like [Scrap.TF](https://scrap.tf), [CS.MONEY](https://cs.money), and [CSG0.Trade](https://csg0.trade) all use some sort of steam bot. In this course, you will learn how to create everything from chat bots to fully-functioning trade websites. From 63cd262d52a254656b3341f1be7383fa46b51bf0 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Tue, 12 Jun 2018 17:49:41 -0700 Subject: [PATCH 15/27] Updated Chapter 6.2, 6.3 --- .../Chapter 6.2 - Getting Started/README.md | 21 +++++++++++-------- .../project10/views/deposit.hbs | 7 ++++--- .../project10/views/main.hbs | 7 ++++--- .../project10/views/withdraw.hbs | 7 ++++--- .../project10/views/deposit.hbs | 7 ++++--- .../project10/views/main.hbs | 7 ++++--- .../project10/views/withdraw.hbs | 7 ++++--- 7 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/README.md b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/README.md index 3fd86ec..fd72fb4 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/README.md +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/README.md @@ -22,11 +22,12 @@ templates using Handlebars. First let's create a couple new views: `deposit
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - ``` @@ -45,11 +46,12 @@ templates using Handlebars. First let's create a couple new views: `deposit
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - ``` @@ -75,11 +77,12 @@ Then we'll change our `main.hbs`: {{else}} Click here to login {{/if}} + + + + - - - ``` diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/deposit.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/deposit.hbs index d31b3e2..58b6695 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/deposit.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/deposit.hbs @@ -10,9 +10,10 @@
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/main.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/main.hbs index 4483d9a..61b2b99 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/main.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/main.hbs @@ -15,9 +15,10 @@ {{else}} Click here to login {{/if}} + + + + - - - diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/withdraw.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/withdraw.hbs index 126a9e8..55f89a7 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/withdraw.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.2 - Getting Started/project10/views/withdraw.hbs @@ -10,9 +10,10 @@
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/deposit.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/deposit.hbs index d31b3e2..58b6695 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/deposit.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/deposit.hbs @@ -10,9 +10,10 @@
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/main.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/main.hbs index 4483d9a..61b2b99 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/main.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/main.hbs @@ -15,9 +15,10 @@ {{else}} Click here to login {{/if}} + + + + - - - diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/withdraw.hbs b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/withdraw.hbs index 126a9e8..55f89a7 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/withdraw.hbs +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.3 - Beginning the Connection/project10/views/withdraw.hbs @@ -10,9 +10,10 @@
  • {{this.name}} (${{this.price}})
  • {{/each}} + + + + - - - From 3567f02e77dfb126379638f5fe07027f6942a152 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Tue, 12 Jun 2018 18:58:13 -0700 Subject: [PATCH 16/27] Chapter 7 added --- .../Chapter 7.1 - Simple Updates/README.md | 45 ++++ .../project11/app.js | 234 ++++++++++++++++++ .../project11/config.json | 4 + .../project11/helpers/priceUpdater.js | 41 +++ .../project11/models/inventory.js | 14 ++ .../project11/models/item.js | 8 + .../project11/models/price.js | 6 + .../project11/models/user.js | 8 + .../project11/public/main.js | 21 ++ .../project11/views/deposit.hbs | 19 ++ .../project11/views/main.hbs | 33 +++ .../project11/views/withdraw.hbs | 19 ++ .../README.md | 13 + .../package.json | 21 ++ README.md | 5 +- 15 files changed, 489 insertions(+), 2 deletions(-) create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/app.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/config.json create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/helpers/priceUpdater.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/inventory.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/item.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/price.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/user.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/public/main.js create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/deposit.hbs create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/main.hbs create mode 100644 Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/withdraw.hbs create mode 100644 Chapter 7 - Updating the Handlebars Frontend/README.md create mode 100644 Chapter 7 - Updating the Handlebars Frontend/package.json diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md new file mode 100644 index 0000000..57ca0b8 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md @@ -0,0 +1,45 @@ +# Chapter 7.1 - Simple Updates + +We'll be using our code from [Chapter 6.3](../../Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.3%20-%20Beginning%20the%20Connection). Let's name it `project11`. + +First we'll edit `./views/main.hbs`... + +```html + + + + + + Steam Trades + + + + {{#if user}} +
    +

    Welcome, {{user.personaname}} +

    +
    +

    You have {{#if user.credits}}{{user.credits}}{{else}}0{{/if}} credits

    +
    + +
    +
    +
  • Logout
  • +
    + {{else}} + + {{/if}} + + + + + + + +``` +We added `Font-Awesome` support & made use of it. Also, many `div` containers have been created, and `class` tags added. diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/app.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/app.js new file mode 100644 index 0000000..a3e5920 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/app.js @@ -0,0 +1,234 @@ +const express = require('express'); +const handlebars = require('express-handlebars'); +const session = require('express-session'); +const cookieParser = require('cookie-parser'); +const passportSocket = require('passport.socketio'); +const async = require('async'); +const passport = require('passport'); +const SteamStrategy = require('passport-steam').Strategy; +const path = require('path'); +const mongoose = require('mongoose'); +const http = require('http'); +const socket = require('socket.io'); +const MongoStore = require('connect-mongo')(session); +const SteamCommunity = require('steamcommunity'); + +const Inventory = require('./models/inventory'); +const Item = require('./models/item'); +const User = require('./models/user'); +const Price = require('./models/price'); + +const priceUpdater = require('./helpers/priceUpdater'); + +const app = express(); +const server = http.Server(app); +const io = socket(server); +const hbs = handlebars.create(); +const community = new SteamCommunity(); +const sessionStore = new MongoStore({ + mongooseConnection: mongoose.connection +}); + +mongoose.connect('mongodb://127.0.0.1:27017/guide'); +priceUpdater(6 * 60 * 60 * 1000); + +passport.serializeUser((user, done) => { + User.update( + { + steamid: user.id + }, + { + $set: user._json + }, + { upsert: true }, + err => { + done(err, user._json); + } + ); +}); + +passport.deserializeUser((obj, done) => { + User.findOne( + { + steamid: obj.steamid + }, + (err, user) => { + done(err, user); + } + ); +}); + +passport.use( + new SteamStrategy( + { + returnURL: 'http://localhost:3037/auth/steam/return', + realm: 'http://localhost:3037/', + apiKey: config.apiKey + }, + (identifier, profile, done) => { + return done(null, profile); + } + ) +); + +io.use( + passportSocket.authorize({ + cookieParser: cookieParser, + key: 'U_SESSION', + secret: config.secretString, + store: sessionStore + }) +); + +io.on('connection', socket => { + socket.on('deposit', data => { + const user = socket.request.user; + console.log(`${user.personaname} is depositting ${data.assetid}`); + // we'll send the trade offer here + }); + + socket.on('withdraw', data => { + const user = socket.request.user; + console.log(`${user.personaname} is withdrawing ${data.assetid}`); + // we'll send the trade offer here + }); +}); + +app.engine('hbs', hbs.engine); +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'hbs'); + +app.use( + session({ + secret: config.secretString, + name: 'U_SESSION', + resave: true, + saveUninitialized: true, + store: sessionStore + }) +); + +app.use(passport.initialize()); +app.use(passport.session()); +app.use(express.static('public')); +app.use(cookieParser()); + +app.get('/', (req, res) => { + res.render('main', { + user: req.user + }); +}); + +app.get('/deposit', (req, res) => { + if (req.user) { + Inventory.findOne( + { + steamid: req.user.steamid + }, + (err, inv) => { + if (inv && Date.now() - inv.updated < 6 * 60 * 60 * 1000) { + res.render('deposit', { + user: req.user, + items: inv.items + }); + } else { + community.getUserInventoryContents( + req.user.steamid, + 730, + 2, + true, + (err, inv) => { + if (err) { + console.log(err); + } else { + async.map( + inv, + (item, done) => { + Price.findOne( + { + market_hash_name: item.market_hash_name + }, + (err, doc) => { + item.price = doc ? doc.price : '?'; + done(null, item); + } + ); + }, + (err, results) => { + Inventory.update( + { + steamid: req.user.steamid + }, + { + $set: { + updated: Date.now(), + items: results + } + }, + err => { + if (err) { + console.log(err); + } + } + ); + + res.render('deposit', { + user: req.user, + items: results + }); + } + ); + } + } + ); + } + } + ); + } else { + res.redirect('/auth/steam'); + } +}); + +app.get('/withdraw', (req, res) => { + if (req.user) { + Item.find({}, (err, inv) => { + async.map( + inv, + (item, done) => { + Price.findOne( + { + market_hash_name: item.name + }, + (err, doc) => { + item.price = doc ? doc.price : '?'; + done(null, item.toObject()); + } + ); + }, + (err, results) => { + res.render('withdraw', { + user: req.user, + items: results + }); + } + ); + }); + } else { + res.redirect('/auth/steam'); + } +}); + +app.get( + /^\/auth\/steam(\/return)?$/, + passport.authenticate('steam', { failureRedirect: '/' }), + (req, res) => { + res.redirect('/'); + } +); + +app.get('/logout', (req, res) => { + req.logout(); + res.redirect('/'); +}); + +server.listen(3037); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/config.json b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/config.json new file mode 100644 index 0000000..242c679 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/config.json @@ -0,0 +1,4 @@ +{ + "apiKey": "", + "secretString": "" +} diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/helpers/priceUpdater.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/helpers/priceUpdater.js new file mode 100644 index 0000000..9b8ca91 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/helpers/priceUpdater.js @@ -0,0 +1,41 @@ +const _ = require('lodash'); +const request = require('request'); + +const Price = require('../models/price'); + +module.exports = interval => { + update(); + + setInterval(update, interval); +}; + +function update() { + request('https://api.csgofast.com/price/all', (err, response, body) => { + if (err) { + console.log(err); + } else { + let json = {}; + + try { + json = JSON.parse(body); + } catch (e) { + console.log(e); + } + + _.forOwn(json, (price, market_hash_name) => { + Price.update( + { market_hash_name }, + { + $set: { price } + }, + { upsert: true }, + err => { + if (err) { + console.log(err); + } + } + ); + }); + } + }); +} diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/inventory.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/inventory.js new file mode 100644 index 0000000..6d363ad --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/inventory.js @@ -0,0 +1,14 @@ +const mongoose = require('mongoose'); + +module.exports = mongoose.model('Inventory', { + steamid: String, + updated: Number, + items: [ + { + market_name: String, + assetid: String, + image: String, + price: Number + } + ] +}); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/item.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/item.js new file mode 100644 index 0000000..8ccf63e --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/item.js @@ -0,0 +1,8 @@ +const mongoose = require('mongoose'); + +module.exports = mongoose.model('Item', { + market_hash_name: String, + assetid: String, + image: String, + price: Number +}); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/price.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/price.js new file mode 100644 index 0000000..b87affd --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/price.js @@ -0,0 +1,6 @@ +const mongoose = require('mongoose'); + +module.exports = mongoose.model('Price', { + market_hash_name: String, + price: Number +}); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/user.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/user.js new file mode 100644 index 0000000..58161d4 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/models/user.js @@ -0,0 +1,8 @@ +const mongoose = require('mongoose'); + +module.exports = mongoose.model('User', { + steamid: String, + personaname: String, + avatar: String, + avatarfull: String +}); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/public/main.js b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/public/main.js new file mode 100644 index 0000000..243088c --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/public/main.js @@ -0,0 +1,21 @@ +var socket = io(); + +$( + (function() { + $('.deposit.item').click(function(one, two) { + socket.emit('deposit', { + assetid: $(this).data('assetid') + }); + + alert('We will send you a tradeoffer for your ' + $(this).text()); + }); + + $('.withdraw.item').click(function(one, two) { + socket.emit('withdraw', { + assetid: $(this).data('assetid') + }); + + alert('We will send you a tradeoffer with a ' + $(this).text()); + }); + })() +); diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/deposit.hbs b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/deposit.hbs new file mode 100644 index 0000000..58b6695 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/deposit.hbs @@ -0,0 +1,19 @@ + + + + Deposit + + +

    Deposit Items

    +
      + {{#each items}} +
    • {{this.name}} (${{this.price}})
    • + {{/each}} +
    + + + + + + + diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/main.hbs b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/main.hbs new file mode 100644 index 0000000..ef0f919 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/main.hbs @@ -0,0 +1,33 @@ + + + + Steam Trades + + + {{#if user}} +
    +

    Welcome, {{user.personaname}} +

    +
    +

    You have {{#if user.credits}}{{user.credits}}{{else}}0{{/if}} credits

    +
    + +
    +
    +
  • Logout
  • +
    + {{else}} + + {{/if}} + + + + + + + diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/withdraw.hbs b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/withdraw.hbs new file mode 100644 index 0000000..55f89a7 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/project11/views/withdraw.hbs @@ -0,0 +1,19 @@ + + + + Withdraw + + +

    Withdraw Items

    +
      + {{#each items}} +
    • {{this.name}} (${{this.price}})
    • + {{/each}} +
    + + + + + + + diff --git a/Chapter 7 - Updating the Handlebars Frontend/README.md b/Chapter 7 - Updating the Handlebars Frontend/README.md new file mode 100644 index 0000000..3204de0 --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/README.md @@ -0,0 +1,13 @@ +# Chapter 7 - Updating the Handlebars Frontend + +## Table of Contents + +- [Chapter 7.1 - Simple Updates](./Chapter%207.1%20-%20Simple%20Updates) + +## Summary + +This chapter will be about updating the handlebars frontend. + +## Authors + +This chapter was written by [@xmwx38](https://github.com/xmwx38). diff --git a/Chapter 7 - Updating the Handlebars Frontend/package.json b/Chapter 7 - Updating the Handlebars Frontend/package.json new file mode 100644 index 0000000..7f6f6fe --- /dev/null +++ b/Chapter 7 - Updating the Handlebars Frontend/package.json @@ -0,0 +1,21 @@ +{ + "name": "project10", + "version": "1.0.0", + "license": "CC-BY-4.0", + "dependencies": { + "connect-mongo": "^1.3.2", + "express": "^4.15.3", + "express-handlebars": "^3.0.0", + "express-session": "^1.15.3", + "mongoose": "^4.11.1", + "morgan": "^1.8.2", + "passport": "^0.3.2", + "passport-steam": "^1.0.8", + "passport.socketio": "^3.7.0", + "socket.io": "^2.0.3", + "steam-totp": "^2.0.1", + "steam-tradeoffer-manager": "^2.8.0", + "steam-user": "^3.21.7", + "steamcommunity": "^3.31.0" + } +} diff --git a/README.md b/README.md index e54aee4..3bd9738 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Andrew's Guide to Steam Bots +# [Steam-Bot-Basics](https://github.com/Steam-Bot-Basics)'s Guide to Steam Bots [![Codacy][codacy-img]][codacy-url] @@ -37,7 +37,8 @@ A complete guide to building Steam bots using Node.js. - [Chapter 6.1 - Prerequisites](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.1%20-%20Prerequisites) - [Chapter 6.2 - Getting Started](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.2%20-%20Getting%20Started) - [Chapter 6.3 - Beginning the Connection](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.3%20-%20Beginning%20the%20Connection) - +- [Chapter 7 - Updating the Handlebars Frontend](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend) + - [Chapter 7.1 - Simple Updates](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend/Chapter%207.1%20-%20Simple%20Updates) *(more chapters to come)* From 37e77fe2a0ca4c928a05282f727be122553347b1 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Tue, 12 Jun 2018 19:19:04 -0700 Subject: [PATCH 17/27] Ch. 7 added; Updated README.md - Ch. 7.1 --- .../Chapter 7.1 - Simple Updates/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md index 57ca0b8..2cb3563 100644 --- a/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md +++ b/Chapter 7 - Updating the Handlebars Frontend/Chapter 7.1 - Simple Updates/README.md @@ -42,4 +42,4 @@ First we'll edit `./views/main.hbs`... ``` -We added `Font-Awesome` support & made use of it. Also, many `div` containers have been created, and `class` tags added. +We added `Font-Awesome` support & made use of it. Also, many `div` containers have been created, and `class` tags added. The login message has been changed, and a Steam icon added to it. The "welcome" header now includes the user's avatar after their name. Their have been some style additions to the headers. A list container was added to the "Deposit", "Withdraw", and "Logout" buttons. From a68960bf77919bb6ae718eaafb80b4eddb6c8e39 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Thu, 14 Jun 2018 01:42:46 -0700 Subject: [PATCH 18/27] Ch. 6.1 - Update README.md - [`cookie-parser`](https://www.npmjs.com/package/cookie-parser) --- .../Chapter 6.1 - Prerequisites/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md b/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md index 6054a50..64b471f 100644 --- a/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md +++ b/Chapter 6 - Connecting Sites and Bots/Chapter 6.1 - Prerequisites/README.md @@ -4,6 +4,7 @@ The dependencies we need for this chapter: - [`passport.socketio`](https://www.npmjs.com/package/passport.socketio) - [`connect-mongo`](https://www.npmjs.com/package/connect-mongo) +- [`cookie-parser`](https://www.npmjs.com/package/cookie-parser) - Install [`MongoDB`](https://docs.mongodb.com/manual/installation) CLI [Continue Reading](../Chapter%206.2%20-%20Getting%20Started) From db6f5f41ea54e13f89ea8214e210dbc230dba38d Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Tue, 26 Jun 2018 13:32:54 -0700 Subject: [PATCH 19/27] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3bd9738..8e3470b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# [Steam-Bot-Basics](https://github.com/Steam-Bot-Basics)'s Guide to Steam Bots +# Guide to Steam Bots +### Forked from [andrewda/node-steam-guide](https://github.com/andrewda/node-steam-guide) [![Codacy][codacy-img]][codacy-url] From 36d57792a201b36940f455680246b8ed58237d8b Mon Sep 17 00:00:00 2001 From: DentFuse Date: Sun, 21 Oct 2018 15:48:41 +0530 Subject: [PATCH 20/27] Added Chapter 3.3 - Sending Group Invites --- .../README.md | 37 ++++++++++++++++++ .../config.json | 6 +++ .../project4.js | 39 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md create mode 100644 Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/config.json create mode 100644 Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js diff --git a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md new file mode 100644 index 0000000..add1605 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md @@ -0,0 +1,37 @@ +# Sending Group Invites + +Now after adding friends we might want to send them friend invites, +to do this we use the `inviteToGroup` method from the `steam-user` module. + +The `inviteToGroup` method takes 2 parameters, the user's steam id to +whom the invite will be sent and the group id of the group. Also the +recipient must be a friend of the bot. +```js +inviteToGroup(userSteamID, groupSteamID) +``` + +Now let's assume that the steam id and the group id are stored in the +variables `steamid` and `groupid` repectively. Here's how we'll use them +to send a group invite. + +```js +client.inviteToGroup(steamid, groupSteamID); +``` + +This can easily be integrated with the chat system as follows: + + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "!group") { + client.chatMessage(steamid,"Sending you a Group Invite!"); + client.inviteToGroup(steamid, groupSteamID); + } +}); +``` + +This will send a group invite to the message sender whenever he sends us +a `!group` message. + +This chapter was written by [@DentFuse](https://github.com/DentFuse) for +[Steam-Bot-Basics/node-steam-guide](https://github.com/Steam-Bot-Basics/node-steam-guide). diff --git a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/config.json b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/config.json new file mode 100644 index 0000000..4eca841 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/config.json @@ -0,0 +1,6 @@ +{ + "username": "", + "password": "", + "sharedSecret": "", + "groupID": "" +} diff --git a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js new file mode 100644 index 0000000..f3e7f0f --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js @@ -0,0 +1,39 @@ +const SteamUser = require('steam-user'); +const SteamTotp = require('steam-totp'); +const config = require('./config.json'); + +const client = new SteamUser(); + +const logOnOptions = { + accountName: config.username, + password: config.password, + twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret) +}; + +client.logOn(logOnOptions); + +client.on('loggedOn', () => { + console.log('Logged into Steam'); + + client.setPersona(SteamUser.Steam.EPersonaState.Online); + client.gamesPlayed(440); +}); + +client.on('friendRelationship', (steamid, relationship) => { + if (relationship === 2) { + client.addFriend(steamid); + client.chatMessage(steamid, 'Hello there! Thanks for adding me!'); + } +}); +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else if (message === "Hey") { + client.chatMessage(steamid,"Hey There !") + } else if (message === "!group") { + client.chatMessage(steamid,"Sending you a Group Invite!"); + client.inviteToGroup(steamid, config.groupID); + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); \ No newline at end of file From 078e52ca9c6bb35c2009b92959b4c69504c71ec1 Mon Sep 17 00:00:00 2001 From: DentFuse Date: Sun, 21 Oct 2018 15:56:38 +0530 Subject: [PATCH 21/27] Added in index --- Chapter 3 - User Interaction/README.md | 1 + README.md | 33 +++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Chapter 3 - User Interaction/README.md b/Chapter 3 - User Interaction/README.md index fa1af61..d0fde4b 100644 --- a/Chapter 3 - User Interaction/README.md +++ b/Chapter 3 - User Interaction/README.md @@ -4,6 +4,7 @@ - [Chapter 3.1 - Friend Requests](./Chapter%203.1%20-%20Friend%20Requests) - [Chapter 3.2 - Chatting With Friends](./Chapter%203.2%20-%20Chatting%20With%20Friends) +- [Chapter 3.3 - Sending Friend Invites](./Chapter%203.3%20-%20Sending%20Group%20Invites) ## Summary diff --git a/README.md b/README.md index 8e3470b..39268f9 100644 --- a/README.md +++ b/README.md @@ -15,28 +15,29 @@ A complete guide to building Steam bots using Node.js. - [Chapter 1.1 - Introduction](./Chapter%201%20-%20Basics/Chapter%201.1%20-%20Introduction) - [Chapter 1.2 - Prerequisites](./Chapter%201%20-%20Basics/Chapter%201.2%20-%20Prerequisites) - [Chapter 1.3 - Starting to Code](./Chapter%201%20-%20Basics/Chapter%201.3%20-%20Starting%20to%20Code) - - [Chapter 1.4 - TOTP](./Chapter%201%20-%20Basics/Chapter%201.4%20-%20TOTP) - - [Chapter 1.5 - Errors](./Chapter%201%20-%20Basics/Chapter%201.5%20-%20Errors) + - [Chapter 1.4 - TOTP](./Chapter%201%20-%20Basics/Chapter%201.4%20-%20TOTP) + - [Chapter 1.5 - Errors](./Chapter%201%20-%20Basics/Chapter%201.5%20-%20Errors) - [Chapter 2 - Trading](./Chapter%202%20-%20Trading) - - [Chapter 2.1 - Prerequisites](./Chapter%202%20-%20Trading/Chapter%202.1%20-%20Prerequisites) - - [Chapter 2.2 - Handling Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.2%20-%20Handling%20Trade%20Offers) - - [Chapter 2.3 - Sending Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.3%20-%20Sending%20Trade%20Offers) - - [Chapter 2.4 - Accepting Donations](./Chapter%202%20-%20Trading/Chapter%202.4%20-%20Accepting%20Donations) + - [Chapter 2.1 - Prerequisites](./Chapter%202%20-%20Trading/Chapter%202.1%20-%20Prerequisites) + - [Chapter 2.2 - Handling Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.2%20-%20Handling%20Trade%20Offers) + - [Chapter 2.3 - Sending Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.3%20-%20Sending%20Trade%20Offers) + - [Chapter 2.4 - Accepting Donations](./Chapter%202%20-%20Trading/Chapter%202.4%20-%20Accepting%20Donations) - [Chapter 3 - User Interaction](./Chapter%203%20-%20User%20Interaction) - - [Chapter 3.1 - Friend Requests](./Chapter%203%20-%20User%20Interaction/Chapter%203.1%20-%20Friend%20Requests) + - [Chapter 3.1 - Friend Requests](./Chapter%203%20-%20User%20Interaction/Chapter%203.1%20-%20Friend%20Requests) - [Chapter 3.2 - Chatting With Friends](./Chapter%203%20-%20User%20Interaction/Chapter%203.2%20-%20Chatting%20With%20Friends) + - [Chapter 3.3 - Sending Friend Invites](./Chapter%203%20-%20User%20Interaction/Chapter%203.3%20-%20Sending%20Group%20Invites) - [Chapter 4 - Basics of Web Development](./Chapter%204%20-%20Basics%20of%20Web%20Development) - - [Chapter 4.1 - Prerequisites](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.1%20-%20Prerequisites) - - [Chapter 4.2 - Base App](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.2%20-%20Base%20App) - - [Chapter 4.3 - Templates](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.3%20-%20Templates) - - [Chapter 4.4 - Databases](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.4%20-%20Databases) - - [Chapter 4.5 - WebSockets](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.5%20-%20WebSockets) + - [Chapter 4.1 - Prerequisites](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.1%20-%20Prerequisites) + - [Chapter 4.2 - Base App](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.2%20-%20Base%20App) + - [Chapter 4.3 - Templates](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.3%20-%20Templates) + - [Chapter 4.4 - Databases](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.4%20-%20Databases) + - [Chapter 4.5 - WebSockets](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.5%20-%20WebSockets) - [Chapter 5 - Advanced Web Development](./Chapter%205%20-%20Advanced%20Web%20Development) - - [Chapter 5.1 - Prerequisites](./Chapter%205%20-%20Advanced%20Web%20Development/Chapter%205.1%20-%20Prerequisites) - - [Chapter 5.2 - Authentication](./Chapter%205%20-%20Advanced%20Web%20Development/Chapter%205.2%20-%20Authentication) + - [Chapter 5.1 - Prerequisites](./Chapter%205%20-%20Advanced%20Web%20Development/Chapter%205.1%20-%20Prerequisites) + - [Chapter 5.2 - Authentication](./Chapter%205%20-%20Advanced%20Web%20Development/Chapter%205.2%20-%20Authentication) - [Chapter 6 - Connecting Sites and Bots](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots) - - [Chapter 6.1 - Prerequisites](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.1%20-%20Prerequisites) - - [Chapter 6.2 - Getting Started](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.2%20-%20Getting%20Started) + - [Chapter 6.1 - Prerequisites](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.1%20-%20Prerequisites) + - [Chapter 6.2 - Getting Started](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.2%20-%20Getting%20Started) - [Chapter 6.3 - Beginning the Connection](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.3%20-%20Beginning%20the%20Connection) - [Chapter 7 - Updating the Handlebars Frontend](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend) - [Chapter 7.1 - Simple Updates](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend/Chapter%207.1%20-%20Simple%20Updates) From 4801d0bada3d0b1eab07212879da1849da3e3589 Mon Sep 17 00:00:00 2001 From: DentFuse Date: Tue, 23 Oct 2018 18:38:02 +0530 Subject: [PATCH 22/27] Added commenting and removing friends --- .../README.md | 18 +++++++++++++++++- .../project4.js | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md index add1605..3986cbe 100644 --- a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md +++ b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/README.md @@ -1,6 +1,6 @@ # Sending Group Invites -Now after adding friends we might want to send them friend invites, +Now after adding friends we might want to send them group invites, to do this we use the `inviteToGroup` method from the `steam-user` module. The `inviteToGroup` method takes 2 parameters, the user's steam id to @@ -33,5 +33,21 @@ client.on('friendMessage', (steamid, message) => { This will send a group invite to the message sender whenever he sends us a `!group` message. +An alternative to this would be to use the `inviteUserToGroup` method of the +`steamcommunity` module. There isn't much difference, the same parameters are +taken by `inviteUserToGroup` too. + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "!group") { + client.chatMessage(steamid,"Sending you a Group Invite!"); + community.inviteUserToGroup(steamid, groupSteamID); + } +}); +``` + +A working example of this has been added to the `project4.js` file, please +refer to it if you have any issues. + This chapter was written by [@DentFuse](https://github.com/DentFuse) for [Steam-Bot-Basics/node-steam-guide](https://github.com/Steam-Bot-Basics/node-steam-guide). diff --git a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js index f3e7f0f..6208508 100644 --- a/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js +++ b/Chapter 3 - User Interaction/Chapter 3.3 - Sending Group Invites/project4.js @@ -33,6 +33,8 @@ client.on('friendMessage', (steamid, message) => { } else if (message === "!group") { client.chatMessage(steamid,"Sending you a Group Invite!"); client.inviteToGroup(steamid, config.groupID); + // OR + community.inviteUserToGroup(steamid, config.groupID); } else { client.chatMessage(steamid,"I failed to understand you :/") } From 281736c96df741305c1ea5509f9d92b148b8b8ac Mon Sep 17 00:00:00 2001 From: DentFuse Date: Tue, 23 Oct 2018 18:38:47 +0530 Subject: [PATCH 23/27] Commenting and Removing friends --- .../README.md | 38 +++++++++++++++ .../config.json | 6 +++ .../project4.js | 47 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/README.md create mode 100644 Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/config.json create mode 100644 Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js diff --git a/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/README.md b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/README.md new file mode 100644 index 0000000..b727351 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/README.md @@ -0,0 +1,38 @@ +# Commenting On User's Profile & Removing Friends + +The `steamcommunity` module also provides us a method to post +comments on a user's profile. this method is `postUserComment` +It takes two parameters, one being the `steamid` of the user, +and the other being the `message` to be posted. + +```js +community.postUserComment(steamid,"My comment"); +``` + +This can also be easily integrated with the chat system: + +```js +client.on('friendMessage', (steamid, message) => { + if (message === "!comment") { + client.chatMessage(steamid,"Commenting on your profile!"); + community.postUserComment(steamid, "My comment"); + } +}); +``` + +Now about removing friends. The bot, like any other user has a limit +to the number of friends he can have. So we need to make sure that old +friends, who haven't traded or chatted with the bot in a long time are removed. +To do this we `removeFriend` method from the `steamcommunity` module. + +The `removeFriend` takes one parameter, the steamid of the user to remove. + +```js +client.removeFriend(steamid); +``` + +So this is the basics of user interaction. final code has been added to the +`project4.js` file, check it out if you have any problems. + +This chapter was written by [@DentFuse](https://github.com/DentFuse) for +[Steam-Bot-Basics/node-steam-guide](https://github.com/Steam-Bot-Basics/node-steam-guide). diff --git a/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/config.json b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/config.json new file mode 100644 index 0000000..4eca841 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/config.json @@ -0,0 +1,6 @@ +{ + "username": "", + "password": "", + "sharedSecret": "", + "groupID": "" +} diff --git a/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js new file mode 100644 index 0000000..df10720 --- /dev/null +++ b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js @@ -0,0 +1,47 @@ +const SteamUser = require('steam-user'); +const SteamTotp = require('steam-totp'); +const config = require('./config.json'); + +const client = new SteamUser(); + +const logOnOptions = { + accountName: config.username, + password: config.password, + twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret) +}; + +client.logOn(logOnOptions); + +client.on('loggedOn', () => { + console.log('Logged into Steam'); + + client.setPersona(SteamUser.Steam.EPersonaState.Online); + client.gamesPlayed(440); +}); + +client.on('friendRelationship', (steamid, relationship) => { + if (relationship === 2) { + client.addFriend(steamid); + client.chatMessage(steamid, 'Hello there! Thanks for adding me!'); + } +}); +client.on('friendMessage', (steamid, message) => { + if (message === "Hello") { + client.chatMessage(steamid,"Hello There !"); + } else if (message === "Hey") { + client.chatMessage(steamid,"Hey There !") + } else if (message === "!group") { + client.chatMessage(steamid,"Sending you a Group Invite!"); + client.inviteToGroup(steamid, config.groupID); + // OR + community.inviteUserToGroup(steamid, config.groupID); + } else if (message === "!comment") { + client.chatMessage(steamid,"Commenting on your profile!"); + community.postUserComment(steamid, "My comment"); + } else if (message === "!remove") { + client.chatMessage(steamid,"See you again later...") + client.removeFriend(steamid) + } else { + client.chatMessage(steamid,"I failed to understand you :/") + } +}); \ No newline at end of file From 364f48edd706c07e183ea63f669e4795e3013cb4 Mon Sep 17 00:00:00 2001 From: Shivam Dwivedi Date: Tue, 23 Oct 2018 22:15:46 +0530 Subject: [PATCH 24/27] Add newline at EOF --- .../project4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js index df10720..9ec170d 100644 --- a/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js +++ b/Chapter 3 - User Interaction/Chapter 3.4 - Commenting on Profile & Removing Friends/project4.js @@ -44,4 +44,4 @@ client.on('friendMessage', (steamid, message) => { } else { client.chatMessage(steamid,"I failed to understand you :/") } -}); \ No newline at end of file +}); From 85dc900ed9b435410fcecc469996d96cac39dace Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Sun, 25 Nov 2018 01:03:41 -0800 Subject: [PATCH 25/27] Update Chapter 1.1 README.md - Headers/Titles redone, - Links updated, - Added another bullet point to first section, - Second section has been added to with details and examples regarding APIs. --- .../Chapter 1.1 - Introduction/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md index 82f7331..66d5ff6 100644 --- a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md +++ b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md @@ -1,12 +1,16 @@ -# Chapter 1.1 - Introduction +# Chapter 1.1 - Introduction -Steam bots can perform many functions: - - Accept donations, - - Chat with individuals or in group chats, - - Send, accept/decline, and confirm trades (automated). +### What kind of tasks can bots perform? +Steam bots can be used for many things: + - Donation Bots + - Chat bots + - Trade bots (in Steam or connected to a website) + - Giveaways -Websites like [Scrap.TF](https://scrap.tf), [CS.MONEY](https://cs.money), and [CSG0.Trade](https://csg0.trade) all use some sort of steam bot. +### What is the purpose of bots and APIs? (w/ examples) +Websites like [scrap.tf](https://scrap.tf), [cs.money](https://cs.money), and [marketplace.tf](https://marketplace.tf) each use their own unique bots that perform functions through Steam (using its API). Websites like these also use services that handle updating prices of Steam items. They often use Steam's Community Market API to handle pricing, or find custom built APIs made by other Steam users. Examples of pricing APIs include [CsGoFast](https://api.csgofast.com/price/all) which is free to use, [BitSkins](https://bitskins.com/api) which offers free basic services, and [OPSkins](https://docs.opskins.com/public/en.html) which offers free services but they limit daily queries to 30,000. +### What will I learn in this course? In this course, you will learn how to create everything from chat bots to fully-functioning trade websites. From acd3268c7c5982ff0382fc8e1f0cc529ffa8bed5 Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Mon, 10 Jun 2019 07:39:54 -0700 Subject: [PATCH 26/27] Chapter 1.1 - Updated README.md --- .../Chapter 1.1 - Introduction/README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md index 66d5ff6..40e78ee 100644 --- a/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md +++ b/Chapter 1 - Basics/Chapter 1.1 - Introduction/README.md @@ -1,17 +1,12 @@ -# Chapter 1.1 - Introduction +# Chapter 1.1 - Introduction -### What kind of tasks can bots perform? Steam bots can be used for many things: - Donation Bots - Chat bots - - Trade bots (in Steam or connected to a website) - - Giveaways + - Trade bots (in steam or connected to a website) -### What is the purpose of bots and APIs? (w/ examples) -Websites like [scrap.tf](https://scrap.tf), [cs.money](https://cs.money), and [marketplace.tf](https://marketplace.tf) each use their own unique bots that perform functions through Steam (using its API). Websites like these also use services that handle updating prices of Steam items. They often use Steam's Community Market API to handle pricing, or find custom built APIs made by other Steam users. Examples of pricing APIs include [CsGoFast](https://api.csgofast.com/price/all) which is free to use, [BitSkins](https://bitskins.com/api) which offers free basic services, and [OPSkins](https://docs.opskins.com/public/en.html) which offers free services but they limit daily queries to 30,000. +Websites like scrap.tf, cs.money, and csgojackpot.com all use some sort of steam bot. -### What will I learn in this course? -In this course, you will learn how to create everything from chat -bots to fully-functioning trade websites. +In the next few sections of Chapter 1, you will learn how to begin setting up your very own bot. [Continue Reading](../Chapter%201.2%20-%20Prerequisites) From 778ac06e6d5892cdcf6a58b2513e26a4612fa24f Mon Sep 17 00:00:00 2001 From: "David, your friend" Date: Mon, 28 Oct 2019 01:40:16 -0700 Subject: [PATCH 27/27] Updated README.md Fixed number list formatting. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 39268f9..9f4555d 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ A complete guide to building Steam bots using Node.js. ## Table of Contents - [Chapter 1 - Basics](./Chapter%201%20-%20Basics) - - [Chapter 1.1 - Introduction](./Chapter%201%20-%20Basics/Chapter%201.1%20-%20Introduction) - - [Chapter 1.2 - Prerequisites](./Chapter%201%20-%20Basics/Chapter%201.2%20-%20Prerequisites) - - [Chapter 1.3 - Starting to Code](./Chapter%201%20-%20Basics/Chapter%201.3%20-%20Starting%20to%20Code) + - [Chapter 1.1 - Introduction](./Chapter%201%20-%20Basics/Chapter%201.1%20-%20Introduction) + - [Chapter 1.2 - Prerequisites](./Chapter%201%20-%20Basics/Chapter%201.2%20-%20Prerequisites) + - [Chapter 1.3 - Starting to Code](./Chapter%201%20-%20Basics/Chapter%201.3%20-%20Starting%20to%20Code) - [Chapter 1.4 - TOTP](./Chapter%201%20-%20Basics/Chapter%201.4%20-%20TOTP) - [Chapter 1.5 - Errors](./Chapter%201%20-%20Basics/Chapter%201.5%20-%20Errors) - [Chapter 2 - Trading](./Chapter%202%20-%20Trading) @@ -22,9 +22,10 @@ A complete guide to building Steam bots using Node.js. - [Chapter 2.2 - Handling Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.2%20-%20Handling%20Trade%20Offers) - [Chapter 2.3 - Sending Trade Offers](./Chapter%202%20-%20Trading/Chapter%202.3%20-%20Sending%20Trade%20Offers) - [Chapter 2.4 - Accepting Donations](./Chapter%202%20-%20Trading/Chapter%202.4%20-%20Accepting%20Donations) -- [Chapter 3 - User Interaction](./Chapter%203%20-%20User%20Interaction) +- [Chapter 3 - User +Interaction](./Chapter%203%20-%20User%20Interaction) - [Chapter 3.1 - Friend Requests](./Chapter%203%20-%20User%20Interaction/Chapter%203.1%20-%20Friend%20Requests) - - [Chapter 3.2 - Chatting With Friends](./Chapter%203%20-%20User%20Interaction/Chapter%203.2%20-%20Chatting%20With%20Friends) + - [Chapter 3.2 - Chatting With Friends](./Chapter%203%20-%20User%20Interaction/Chapter%203.2%20-%20Chatting%20With%20Friends) - [Chapter 3.3 - Sending Friend Invites](./Chapter%203%20-%20User%20Interaction/Chapter%203.3%20-%20Sending%20Group%20Invites) - [Chapter 4 - Basics of Web Development](./Chapter%204%20-%20Basics%20of%20Web%20Development) - [Chapter 4.1 - Prerequisites](./Chapter%204%20-%20Basics%20of%20Web%20Development/Chapter%204.1%20-%20Prerequisites) @@ -38,9 +39,9 @@ A complete guide to building Steam bots using Node.js. - [Chapter 6 - Connecting Sites and Bots](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots) - [Chapter 6.1 - Prerequisites](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.1%20-%20Prerequisites) - [Chapter 6.2 - Getting Started](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.2%20-%20Getting%20Started) - - [Chapter 6.3 - Beginning the Connection](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.3%20-%20Beginning%20the%20Connection) + - [Chapter 6.3 - Beginning the Connection](./Chapter%206%20-%20Connecting%20Sites%20and%20Bots/Chapter%206.3%20-%20Beginning%20the%20Connection) - [Chapter 7 - Updating the Handlebars Frontend](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend) - - [Chapter 7.1 - Simple Updates](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend/Chapter%207.1%20-%20Simple%20Updates) + - [Chapter 7.1 - Simple Updates](./Chapter%207%20-%20Updating%20the%20Handlebars%20Frontend/Chapter%207.1%20-%20Simple%20Updates) *(more chapters to come)*