Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.96 KB | None | 0 0
  1. var Steam = require('steam')
  2. var SteamUser = require('steam-user');
  3. var SteamTotp = require('steam-totp');
  4. var SteamCommunity = require('steamcommunity');
  5. var TradeOfferManager = require('steam-tradeoffer-manager');
  6. var client = new SteamUser();
  7. var friends = new Steam.SteamFriends(client.client);
  8. var community = new SteamCommunity();
  9. var manager = new TradeOfferManager({
  10. steam: client,
  11. community: community,
  12. language: 'en'
  13. });
  14.  
  15. console.log('[STEAM]Logging into Steam')
  16. var logOnOptions = {
  17. accountName: 'EDITME', //username
  18. password: 'EDITME', //password
  19. twoFactorCode: SteamTotp.generateAuthCode('EDITME') //steam shared secret
  20. };
  21.  
  22. trusted_users = []
  23.  
  24. client.logOn(logOnOptions);
  25.  
  26. client.on('loggedOn', () => {
  27. console.log('[STEAM]Logged into Steam');
  28.  
  29. client.setPersona(SteamUser.Steam.EPersonaState.Online, 'Vault Hunter 101');
  30. //client.gamesPlayed(["Steam BOT", 0]); //delete this line to remove feature
  31. //custom game played ^^| => Steam game id of real game played, used for idling
  32. //currently it only plays Team Fortress EDITME, Try changing it :)
  33. //to add more than 1 game do this | client.gamesPlayed(["EDITME", 440, 730]);
  34. //i used CSGO APP id as an example, That is how you add more than one game.
  35.  
  36.  
  37.  
  38. console.log('[STEAM]Now idling selected games');
  39.  
  40. client.on('webSession', (sessionid, cookies) => {
  41. manager.setCookies(cookies);
  42.  
  43. community.setCookies(cookies);
  44. community.startConfirmationChecker(10000, 'EDITME'); //steam identity secret
  45.  
  46. client.on('friendRelationship', (steamid, relationship) => {
  47. if (relationship === 2) {
  48. client.addFriend(steamid);
  49. client.chatMessage(steamid, 'Hello there! I am a BOT. My owner will talk to you soon. Please leave a message why you sent friend request :)'); //message said upon friend accept
  50. console.log('[STEAM]Somone has added you');
  51. }
  52.  
  53. });
  54.  
  55. //Misc
  56.  
  57.  
  58. //Trading stuff
  59.  
  60. manager.on('newOffer', (offer) => {
  61. if (offer.partner.getSteamID64() === 'EDITME ADD TRUSTED ACCOUNT STEAMID HERE') {
  62. offer.accept((err, status) => {
  63. if (err) {
  64. console.log(err);
  65. } else {
  66. console.log(`Accepted offer. Status: ${status}.`);
  67. }
  68. });
  69. }
  70.  
  71. manager.on('newOffer', (offer) => {
  72. if (offer.itemsToGive.length === 0) {
  73. offer.accept((err, status) => {
  74. if (err) {
  75. console.log(err);
  76. } else {
  77. console.log(`Trade Offer. Status: ${status}.`);
  78. }
  79. });
  80. } else {
  81. if (offer.itemsToGive.length === 10000) {
  82. offer.decline((err) => {
  83. if (err) {
  84. console.log(err);
  85. } else {
  86. console.log('Trade Offer | Declined (wanted our items).');
  87. }
  88. });
  89. }
  90. };})})})
  91.  
  92.  
  93. console.log('[STEAM]Trading works')
  94. //chat stuff
  95. //Function(s) made by Caret
  96. //Function(s) (help) send Messages
  97. //chat functions
  98. var returndefaultmessage = false; //default is false. set to true if you want to return a standard message
  99. //default message even if a match is not found in messageresponse list
  100.  
  101. var messageresponse = [
  102. [['ping', 'pinger', 'pingas'], 'Pong!'],
  103. [['bye', 'goodbye', 'good bye', 'gtg', 'cya', 'ttyl'], 'Bye :)'],
  104. [['hello', 'hey', 'hi', 'sup', 'hallo'], 'Hello!'],
  105. [['polski'], 'VAULT HUNTER 101 IS THE BEST!!!!'],
  106. [['hax', 'hacker', 'hacks',], ':D'],
  107. [['help'], 'Aivaible commands are: ping,pong,gg,hello,bye'],
  108. [['pong'], 'Its ping you idiot!'],
  109. [['gg'], 'ez pz'],
  110.  
  111.  
  112.  
  113. ]
  114. //lower case only. function converts incoming messages to lower case
  115. //try adding more responses
  116.  
  117. console.log('[STEAM] Chat works')
  118.  
  119.  
  120. function getreplymessage(usermessage) {
  121. console.log('[STEAM]We have received a message!');
  122. usermessage = usermessage.toLowerCase();
  123. if (usermessage == 'helpmemummy') {
  124. var messagelist = "Possible messages are: ";
  125. for (var i_a = 0; i_a < messageresponse.length; i_a++ ) {
  126. for (var i_b = 0; i_b < messageresponse[i_a][0].length; i_b++ ) {
  127. messagelist += messageresponse[i_a][0][i_b] + ', '
  128. }
  129. }
  130. return [true, messagelist];
  131. }
  132. for (var i_a = 0; i_a < messageresponse.length; i_a++ ) {
  133. for (var i_b = 0; i_b < messageresponse[i_a][0].length; i_b++ ) {
  134. if (usermessage == messageresponse[i_a][0][i_b]) {
  135. return [true, '[BOT] ' + messageresponse[i_a][1]];
  136. }
  137. }
  138. }
  139. return [false, 'DEFAULT']; //returned message when no matches could be found
  140. }
  141.  
  142. var trusted_users = []; //optional, you could authenticate yourself later when the bot is running if needed
  143. var accesspassword = 'VH101BotPassword'; //no spaces allowed. change
  144.  
  145. function istrusted(checkuser) {
  146. for (var i = 0; i < trusted_users.length; i++) {
  147. if (trusted_users[i] == checkuser) {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153.  
  154. var trusted_users = []; //optional, you could authenticate yourself later when the bot is running if needed
  155. var accesspassword = 'VH101BotPassword'; //no spaces allowed. change
  156.  
  157. function istrusted(checkuser) {
  158. for (var i = 0; i < trusted_users.length; i++) {
  159. if (trusted_users[i] == checkuser) {
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165.  
  166. var trusted_users = []; //optional, you could authenticate yourself later when the bot is running if needed
  167. var accesspassword = 'VH101BotPassword'; //no spaces allowed. change
  168.  
  169. function istrusted(checkuser) {
  170. for (var i = 0; i < trusted_users.length; i++) {
  171. if (trusted_users[i] == checkuser) {
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177.  
  178. var trusted_users = []; //optional, you could authenticate yourself later when the bot is running if needed
  179. var accesspassword = 'VH101BotPassword'; //no spaces allowed. change
  180.  
  181. function istrusted(checkuser) {
  182. for (var i = 0; i < trusted_users.length; i++) {
  183. if (trusted_users[i] == checkuser) {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189.  
  190. friends.on("friendMsg", function(user, msg, type){
  191. if(type == Steam.EChatEntryType.ChatMsg && msg.length != 0){
  192. if (msg.charAt(0) != '!'){
  193. var reply = getreplymessage(msg);
  194. if (reply[0]){//is not the default return for no match (there is a match)
  195. friends.sendMessage(user, reply[1]);
  196. }
  197. else if (returndefaultmessage) {
  198. friends.sendMessage(user, reply[1]);
  199. }
  200. return;
  201. }
  202. //below are admin commands
  203. var splitmessage = msg.split(' ');
  204. if (!istrusted(user)) {
  205. if (splitmessage[0].toLowerCase() == '!login') {
  206. if (splitmessage.length != 2) {
  207. friends.sendMessage(user, 'Correct usage: !login password');
  208. return;
  209. }
  210. if (splitmessage[1] == accesspassword) {
  211. friends.sendMessage(user, 'Authenticated');
  212. trusted_users.push(user);
  213. return;
  214. }
  215. friends.sendMessage(user, 'Incorrect password');
  216. return;
  217. }
  218. friends.sendMessage(user, 'You do not have admin privileges. Send !login password to gain access');
  219. return;
  220. }
  221. if (istrusted(user)) {
  222. if (msg == '!idle') {
  223. console.log('[Steam]Command accepted!');
  224. client.gamesPlayed([ ]);
  225. client.gamesPlayed(["Idling GAMES", 440]);//Edit this to change games played upon idle command
  226. friends.sendMessage(user, 'Idling on games...');
  227. }
  228. if (msg == '!idlestop') {
  229. console.log('[Steam]Command accepted!');
  230. client.gamesPlayed([ ]);
  231. friends.sendMessage(user, 'Stopping idle.');
  232. }
  233. if (msg == '!logout') {
  234. console.log('[Steam]Logging user out...');
  235. friends.sendMessage(user, 'Logging you out...');
  236. trusted_users.splice(trusted_users.indexOf(user), 1);
  237. }
  238. return;
  239. }
  240. }
  241. })})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement