sl1029

Brisbane source code

Jul 6th, 2026
47
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.90 KB | None | 0 0
  1. const versionString = "Brisbane V3.3.3 by katiserie (C) 2025-2026";
  2. const admins = ["katiserie","e_g.","gimmickCellar"]; // include your realUsername in the list and exclude any unwanted admins
  3. const fishingChances = {"small_fish": 500, "big_fish": 300, "scrap_metal": 100, "gold_nugget": 5} // lower number = lower chance
  4. var shopItems = {"coin": 40, "fishing_rod": 100, "small_fish": 20, "big_fish": 50, "scrap_metal": 100, "gold_nugget": 1000} // any shop items lie here
  5. var prophetbot = {};
  6. var shopItemEntries = Object.entries(shopItems);
  7. var shopItemNames = [];
  8. for (i=0;i<shopItemEntries.length;i++) {
  9. shopItemNames[i] = shopItemEntries[i][0];
  10. }
  11. var prefix = "b!";
  12. var prefix2 = "β";
  13. var started = false;
  14. var tellonly = false;
  15. var savedPeople = [];
  16. var botUser = {nick: `Brisbane (${prefix2}help/${prefix}help)`, color: "#E4B3FF"}; // feel free to customize
  17. var pageSize = 3; // maximum of n items in a page (for pagination)
  18. var cooldowns = {general: 8, fishing: 48, work: 72};
  19. var cooldownMults = {location: {page: 0.25, global:0.25}, user: {}};
  20. var chatworld = window.location.href;
  21. var universal_cmd_enabled = false;
  22. function unixInSecs() { // returns current unix timestamp in seconds
  23. return Math.round(Date.now()/1000);
  24. }
  25. var startTimestamp = new Date(Date.now().toString());
  26. function newPerson(user, userid, bal, lastMsg) { // adds a new person to the database
  27. let personObject = {username: user, id: userid, name: null, balance: bal, timestamp: lastMsg, cooldowns: {work: 50, fish: 30, general: 10}, inventory: {}, banProps: {banned: false, until: 0}, tips: {cooldown: false}}
  28. if(personObject.username) {
  29. personObject.name = personObject.username;
  30. } else {
  31. personObject.name = personObject.id;
  32. }
  33. console.log(`New user created: [${userid}]${user}.`);
  34. return personObject;
  35. }
  36. function findUser(user2find,userid2find) { // finds user by id or realUsername
  37. let foundUser = savedPeople.find(({ username }) => username === user2find);
  38. if (foundUser == undefined) {
  39. foundUser = savedPeople.find(({ id }) => id === userid2find);
  40. }
  41. return foundUser;
  42. }
  43. function findByName(name2find) {
  44. let foundUser = savedPeople.find(({ name }) => name === name2find);
  45. return foundUser;
  46. }
  47. function randint(min,max) { // returns random integer
  48. return Math.round(Math.random()*(max-min))+min;
  49. }
  50. function handleBal(name, userid, bal, silent, loct, tell) { // handles the balance and creation of users
  51. let personModel = findByName(name);
  52. if(personModel != undefined) {
  53. bal = personModel.balance;
  54. }
  55. if(silent == true){
  56. console.log(`${name} has ${bal}H in their bank account.`,loct, tell, userid);
  57. } else {
  58. sendMsg(`${name} has ${bal}H in their bank account.`,loct, tell, userid);
  59. }
  60. if (personModel == undefined) {
  61. newPerson(name, userid, bal, unixInSecs());
  62. }
  63. }
  64. function handleProphecy(thing,victim,loc,tell,id) {
  65. if (prophetbot[thing] === undefined) {
  66. prophetbot[thing] = {};
  67. if (prophetbot[thing][victim] === undefined) prophetbot[thing][victim] = randint(0,100);
  68. } else {
  69. if (prophetbot[thing][victim] === undefined) prophetbot[thing][victim] = randint(0,100);
  70. }
  71. sendMsg(`[${victim} is ${prophetbot[thing][victim]}% ${thing}]`,loc,tell,id);
  72. }
  73. function sendMsg(msg, loct, tell, userid) { // sends message unless bot is offline
  74. console.log(`message: ${msg}, location: ${loct}, tell: ${tell}, id: ${userid}`)
  75. if (started && tell != "to_me" && tellonly == false) {
  76. socket.send(JSON.stringify({kind: "chat", nickname: botUser.nick, message: `${msg}`, location: loct, color: botUser.color}));
  77. } else if(started && tell == "to_me") {
  78. socket.send(JSON.stringify({kind: "chat", nickname: botUser.nick, message: `/tell ${userid} ${msg}`, location: loct, color: botUser.color}));
  79. } else if(started) {
  80. socket.send(JSON.stringify({kind: "chat", nickname: botUser.nick, message: `/tell ${userid} You must use the /tell command`, location: loct, color: botUser.color}));
  81. } else {
  82. console.log(`There was an attempt to send "${msg}" while the bot was offline`);
  83. }
  84. }
  85. function balMod(user,amount) { // changes a user's balance unless bot is offline
  86. if (started && !isNaN(safeParseInt(amount))) {
  87. user.balance = safeParseInt(user.balance) + safeParseInt(amount);
  88. console.log(`Script added ${amount} to ${user.name}'s bank account`)
  89. } else if (started) {
  90. console.error(`Could not add ${amount} to ${user.name}'s bank account`)
  91. }
  92. }
  93. function invAdd(item,amount,user,ModBal) {
  94. if (!isNaN(safeParseInt(amount)) && amount >= -Math.abs(amount)) {
  95. user.inventory[item] = (safeParseInt(amount) + safeParseInt(user.inventory[item]));
  96. if (ModBal) {balMod(user,-shopItems[item]*amount)};
  97. console.log(`Script bought ${amount} items.`)
  98. } else {
  99. console.error(`Could not add ${amount} to ${user.name}'s inventory.`)
  100. }
  101. if (isNaN(safeParseInt(user.inventory[item]))) {
  102. user.inventory[item] = amount;
  103. }
  104. }
  105. function safeParseInt(int) { // parseint which throws an error
  106. let parsedInt = parseInt(int);
  107. if (!isNaN(parsedInt)) {
  108. if (parsedInt == Infinity) {
  109. return parseInt(0);
  110. } else {
  111. return parseInt(parsedInt);
  112. }
  113. } else {
  114. console.error("THAT IS NOT WHERE A STRING GOES YOU IDIOT");
  115. return parseInt(0);
  116. }
  117. }
  118.  
  119. w.on("chat", function (data) {
  120. if (data.id == 0) return;
  121. var loc = data.location;
  122. var persid = data.id;
  123. var totell = data.dataObj.privateMessage;
  124. var person2find = data.realUsername || data.id
  125. var person = findByName(person2find);
  126. var args = data.message.split(" ");
  127. var personName = args[1];
  128. var foundPerson = findByName(personName);
  129. var personBal = 0;
  130. let page = 1;
  131. let maxPage = 999;
  132. console.log(totell);
  133. if (person == undefined && data.dataObj.privateMessage != "from_me") {
  134. var bal = 50;
  135. person = newPerson(data.realUsername, data.id, bal, unixInSecs());
  136. savedPeople.push(person);
  137. }
  138. if (args[0].startsWith(prefix) || args[0].startsWith(prefix2)){
  139. cmd = args[0].replace(prefix,"");
  140. cmd = cmd.replace(prefix2,"");
  141. } else {
  142. cmd = undefined;
  143. }
  144. if(cmd != undefined && unixInSecs() > person.cooldowns.general) {
  145. person.cooldowns.general = unixInSecs() + cooldowns.general*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1);
  146. switch (cmd.toLowerCase()) {
  147. case "bal":
  148. if (personName == null) {
  149. handleBal(person2find, findByName(person2find).id, findByName(person2find).balance,false,loc,totell,persid);
  150. } else {
  151. personBal = foundPerson.balance
  152. if (!personBal) return sendMsg("Nobody exists with that username or ID.");
  153. handleBal(personName, foundPerson.id, personBal, false,loc,totell,persid);
  154. }
  155. break;
  156. case "donate":
  157. let cashAmt = safeParseInt(args[2])
  158. if (personName == null) {
  159. sendMsg("You must specify a person to donate to.",loc,totell,persid)
  160. } else if (args[2] == null) {
  161. sendMsg("You must specify an amount to donate.",loc,totell,persid)
  162. } else if (personName == data.realUsername || personName == data.id) {
  163. sendMsg("You cannot donate to yourself.",loc,totell,persid)
  164. } else if (safeParseInt(cashAmt) < 0) {
  165. sendMsg("You cannot donate a negative amount of money to a person.",loc,totell,persid)
  166. } else if (safeParseInt(cashAmt) > safeParseInt(person.balance)) {
  167. sendMsg("You cannot donate more than you have in your bank account.",loc,totell,persid)
  168. } else if (cashAmt == Infinity) {
  169. sendMsg("You cannot donate an infinite amount of coins",loc,totell,persid)
  170. } else if (isNaN(cashAmt)) {
  171. sendMsg("Invalid amount of coins to donate.",loc,totell,persid)
  172. } else {
  173. balMod(person, -cashAmt);
  174. balMod(foundPerson, cashAmt);
  175. sendMsg(`You donated ${args[2]} to ${foundPerson.name}`,loc,totell,persid)
  176. }
  177. break;
  178. case "cf":
  179. case "coinflip":
  180. let bets = args.slice(1);
  181. let cfMsg = ``;
  182. if(!person.inventory["coin"]) {
  183. sendMsg(`To obtain a coin, execute ${prefix}buy coin (Cost: 40H).`,loc,totell,persid);
  184. } else if (bets.length > person.inventory["coin"]) {
  185. sendMsg(`You cannot flip more coins than you have in your inventory. \n execute ${prefix}buy coin to obtain one (40H).`,loc,totell,persid);
  186. } else if (bets.length > pageSize) {
  187. let betsAmt = {won: 0, lost: 0, error: 0}
  188. let totalAmt = 0;
  189. let amtWon = 0;
  190. for (betAmt of bets) {
  191. totalAmt += safeParseInt(betAmt);
  192. }
  193. if (totalAmt > person.balance) {
  194. sendMsg("You cannot bet more than you have in your bank account.",loc,totell,persid);
  195. } else {
  196. for (betAmt of bets) {
  197. betAmt = safeParseInt(betAmt);
  198. if (betAmt < 0 || betAmt == Infinity || isNaN(betAmt)) {
  199. betsAmt.error++
  200. } else {
  201. let rand = Math.random();
  202. if (rand >= 0.5) {
  203. betsAmt.won++
  204. amtWon += betAmt;
  205. } else {
  206. betsAmt.lost++
  207. amtWon -= betAmt;
  208. }
  209. }
  210. }
  211. }
  212. sendMsg(`Flipped ${betsAmt.length} coins. You had ${betsAmt.won} wins and ${betsAmt.lost} losses, amounting to ${amtWon}H. You encountered ${betsAmt.error} errors.`,loc,totell,persid);
  213. } else {
  214. let totalAmt = 0;
  215. for (betAmt of bets) {
  216. totalAmt += safeParseInt(betAmt);
  217. }
  218. if (totalAmt > person.balance) {
  219. sendMsg("You cannot bet more than you have in your bank account.",loc,totell,persid);
  220. } else {
  221. for (betAmt of bets) {
  222. betAmt = safeParseInt(betAmt);
  223. if (betAmt < 0) {
  224. cfMsg += "Not flipped: Negative bet amount.\n";
  225. } else if (betAmt == Infinity) {
  226. cfMsg += "Not flipped: Too large.\n";
  227. } else if (isNaN(betAmt)) {
  228. cfMsg += "Not flipped: Invalid bet amount.\n";
  229. } else {
  230. let rand = Math.random();
  231. if (rand >= 0.5) {
  232. cfMsg += `Coinflip won! Earned ${betAmt}H.\n`
  233. balMod(person, betAmt);
  234. } else {
  235. cfMsg += `Coinflip lost! Lost ${betAmt}H.\n`
  236. balMod(person, -betAmt);
  237. }
  238. }
  239. }
  240. }
  241. sendMsg(cfMsg,loc,totell,persid);
  242. }
  243. break;
  244. case "work":
  245. if (person.cooldowns.work-unixInSecs() <= 0) {
  246. console.log(person.cooldowns.work-unixInSecs());
  247. profit = randint(25,50);
  248. balMod(person,profit);
  249. person.cooldowns.work = unixInSecs() + cooldowns.work*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1);
  250. sendMsg(`You have worked and earned ${profit}H. You can work again in ${person.cooldowns.work-unixInSecs()} seconds.`,loc,totell,persid)
  251. } else {
  252. sendMsg(`You can work again in ${person.cooldowns.work-unixInSecs()} seconds.`,loc,totell,persid)
  253. }
  254. break;
  255. case "baltop":
  256. let sortedPeople = savedPeople.slice().sort((a,b) => b.balance - a.balance);
  257. if (args[1]) page = args[1];
  258. maxPage = Math.ceil(page/pageSize);
  259. let leaderboardMsg = `Users by balance: \n`;
  260. if (page > maxPage) leaderboardMsg = `Invalid page.`;;
  261. for (let i = pageSize*(page-1); i < pageSize*page; i++) {
  262. leaderboardMsg+= `${i+1}. ${sortedPeople[i].name} - ${sortedPeople[i].balance}H \n`;
  263. }
  264. leaderboardMsg += `Page ${page.toString()} of ${Math.ceil(sortedPeople.length/pageSize).toString()}. `
  265. if (page == 1) {leaderboardMsg += `Use ${prefix}baltop [page] to view other pages.`};
  266. sendMsg(leaderboardMsg,loc,totell,persid);
  267. break;
  268. case "inv":
  269. let invMsg = ``;
  270. if (args[2]) page = args[2];
  271. maxPage = Math.ceil(page/pageSize);
  272. if (page > maxPage) invMsg = `Invalid page.`;
  273. if (personName == null) {
  274. let inventory = person.inventory;
  275. let partialInv = inventory.slice((page-1)*pageSize,page*pageSize);
  276. invMsg = `Your inventory (Page ${page} of ${Math.ceil(inventory.length/pageSize)}): \n`;
  277. if (person.inventory != {}) {
  278. for (let[key, value] of Object.entries(partialInv)) {
  279. invMsg += `${key} - ${value}\n`;
  280. }
  281. } else {
  282. invMsg += `No items, only us crickets 3:.`;
  283. }
  284. } else if (foundPerson) {
  285. let inventory = foundPerson.inventory;
  286. let partialInv = Object.entries(inventory).slice((page-1)*pageSize,page*pageSize);
  287. invMsg = `${foundPerson.name}'s inventory (Page ${page} of ${Math.ceil(inventory.length/pageSize)}): \n`
  288. if (person.inventory != {}) {
  289. for (let[key, value] of partialInv) {
  290. invMsg += `${key} - ${value}\n`;
  291. }
  292. } else {
  293. invMsg += `${foundPerson.name} has no items here.`;
  294. }
  295. } else {
  296. invMsg = `Could not find ${personName}.`;
  297. }
  298. sendMsg(invMsg,loc,totell,persid);
  299. break;
  300. case "shop":
  301. if (args[1]) page = args[1];
  302. let shopMsg;
  303. maxPage = Math.ceil(Object.entries(shopItems).length/pageSize);
  304. if (page > maxPage) shopMsg = `Invalid page.`;
  305. let partialShopItems = Object.entries(shopItems).slice((page-1)*pageSize,page*pageSize);
  306. shopMsg = `Items in shop (Page ${page} of ${Math.ceil(shopItems.length/pageSize)}): \n`
  307. for (let[key, value] of partialShopItems) {
  308. shopMsg += `${key} - ${value}\n`;
  309. }
  310. shopMsg += `${prefix}buy [item] to buy, b!shop [page] to view other pages.`
  311. sendMsg(shopMsg,loc,totell,persid)
  312. break;
  313. case "buy":
  314. item = args[1];
  315. amount = args[2] || 1;
  316. if (item == null) {
  317. sendMsg("You must specify an item to buy.",loc,totell,persid);
  318. } else if (shopItemNames.indexOf(args[1]) == -1) {
  319. sendMsg(`Item ${item} does not exist.`)
  320. } else if (shopItems[item]*amount > person.balance) {
  321. sendMsg(`You cannot afford ${amount} ${item}s.`,loc,totell,persid);
  322. } else {
  323. sendMsg(`Bought ${amount} ${item}s succesfully.`,loc,totell,persid)
  324. invAdd(item,amount,person,true);
  325. }
  326. break;
  327. case "sell":
  328. item = args[1];
  329. amount = args[2] || 1;
  330. if (item == null) {
  331. sendMsg("You must specify an item to sell.",loc,totell,persid);
  332. } else if (person.inventory[item] < amount) {
  333. sendMsg(`You do not have enough ${item}s to sell ${amount} of them.`,loc,totell,persid);
  334. } else {
  335. sendMsg(`Sold ${amount} ${item}s succesfully.`,loc,totell,persid)
  336. invAdd(item,-amount,person,true);
  337. }
  338. break;
  339. case "fish":
  340. fishChanceList = Object.values(fishingChances);
  341. fishChanceTotal = 0;
  342. caughtSmth = false;
  343. for (fishChance of fishChanceList) {
  344. fishChanceTotal += fishChance
  345. };
  346. if (person.inventory["fishing_rod"] >= 1 && person.cooldowns.fish-unixInSecs() <= 0) {
  347. fishChanceInt = randint(0, fishChanceTotal);
  348. totalValue = 0;
  349. for (let[key,value] of Object.entries(fishingChances)) {
  350. totalValue += value;
  351. if (fishChanceInt < totalValue) {
  352. caughtSmth = true;
  353. person.cooldowns.fish = unixInSecs() + cooldowns.fishing*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1);
  354. invAdd(key,1,person,false);
  355. sendMsg(`Congrats! You have caught a ${key}. ${prefix}sell ${key} to sell. You can fish again in ${person.cooldowns.fish-unixInSecs()} seconds`,loc,totell,persid);
  356. break;
  357. }
  358. }
  359. if (!caughtSmth) {
  360. sendMsg(`Unfortunately, you haven't caught anything. Better luck next time!`,loc,totell,persid);
  361. }
  362. } else if (person.inventory["fishing_rod"] >= 1) {
  363. sendMsg(`You can fish again in ${person.cooldowns.fish-unixInSecs()} seconds.`,loc,totell,persid);
  364. } else {
  365. sendMsg("You must buy a fishing rod from the shop to fish.",loc,totell,persid);
  366. }
  367. break;
  368. case "paw":
  369. var victim = args.slice(1).join(" ");
  370. if (victim == null) {
  371. sendMsg("You must specify someone to paw at.",loc,totell,persid)
  372. } else {
  373. sendMsg(`${person.name} has pawed at ${victim} :3.`,loc,totell,persid)
  374. }
  375. break;
  376. case "claw":
  377. var victim = args.slice(1).join(" ");
  378. if (victim == null) {
  379. sendMsg("You must specify someone to claw at.",loc,totell,persid)
  380. } else {
  381. sendMsg(`${person.name} has clawed at ${victim} 3:<.`,loc,totell,persid)
  382. }
  383. break;
  384. case cmd.startsWith('how') ? cmd : false :
  385. let thing;
  386. var victim;
  387. if (cmd == "how") {
  388. thing = args[1];
  389. victim = args.slice(2).join(" ");
  390. } else {
  391. thing = cmd.replace("how","");
  392. victim = args.slice(1).join(" ");
  393. }
  394. if (thing == null) {
  395. sendMsg("You must specify something.",loc,totell,persid)
  396. } else if (victim == null) {
  397. sendMsg("You must specify someone.",loc,totell,persid);
  398. } else {
  399. handleProphecy(thing,victim,loc,totell,persid);
  400. }
  401. break;
  402. case "vers":
  403. sendMsg(versionString,loc,totell,persid);
  404. break;
  405. case "cooldowns":
  406. let cdMsg = ``;
  407. for (let[key,value] of Object.entries(cooldowns)) {
  408. cdMsg += `${key} cooldown: ${value*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1)} \n`;
  409. }
  410. sendMsg(cdMsg,loc,totell,persid);
  411. break;
  412. case "rate":
  413. let rating;
  414. let ratingScore = randint(0,100);
  415. if (ratingScore > 98) {
  416. rating = "flawless";
  417. } else if (ratingScore > 90) {
  418. rating = "awesome";
  419. } else if (ratingScore > 85) {
  420. rating = "excellent";
  421. } else if (ratingScore > 80) {
  422. rating = "great";
  423. } else if (ratingScore > 60) {
  424. rating = "good";
  425. } else if (ratingScore > 40) {
  426. rating = "neutral";
  427. } else if (ratingScore > 25) {
  428. rating = "bad";
  429. } else if (ratingScore > 15) {
  430. rating = "awful";
  431. } else if (ratingScore > 5) {
  432. rating = "horrible";
  433. } else {
  434. rating = "catastrophic";
  435. }
  436. sendMsg(`I think ${args.slice(1).join(" ")} is ${rating}`,loc,totell,persid);
  437. break;
  438. case "choose":
  439. if (!args[1]) {
  440. sendMsg(`I don't have anything to choose, so I choose pikachu!`,loc,totell,persid);
  441. break;
  442. }
  443. sendMsg(`I choose ${args[randint(1,args.length)]}`,loc,totell,persid);
  444. break;
  445. case "ark":
  446. case "bark":
  447. let barkLetters = ["w","r","u","b"];
  448. let barkAmt = args[1] ? args[1] : 2;
  449. let barkingMsg = "";
  450. let letterAmt;
  451. for (i=1;i<=barkAmt;i++) {
  452. barkingMsg += (Math.random() > 0.5 ? "r" : "a");
  453. letterAmt = randint(3,6);
  454. for (j=1;j<=letterAmt;j++) {
  455. barkingMsg += barkLetters[randint(0,barkLetters.length-1)];
  456. }
  457. barkingMsg += (Math.random() > 0.5 ? "ff" : "");
  458. if (i!=barkAmt) barkingMsg += " ";
  459. }
  460. sendMsg(barkingMsg,loc,totell,persid);
  461. break;
  462. case "meow":
  463. let meowLetters = ["m","r","w","o","e","k","'","a"];
  464. let meowAmt = args[1] ? args[1] : 1;
  465. let meowingMsg = "";
  466. let letterAmt2;
  467. for (i=1;i<=meowAmt;i++) {
  468. meowingMsg += (Math.random() > 0.5 ? "m" : "r");
  469. letterAmt2 = randint(2,6);
  470. for (j=1;j<=letterAmt2;j++) {
  471. meowingMsg += meowLetters[randint(0,meowLetters.length-1)];
  472. }
  473. meowingMsg += (Math.random() > 0.5 ? "pp" : "");
  474. if (i!=meowAmt) meowingMsg += " ";
  475. }
  476. sendMsg(meowingMsg,loc,totell,persid);
  477. break;
  478. case "help":
  479. if(!args[1]) {
  480. sendMsg(`For commands, run the following after ${cooldowns.general*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1)} seconds: ${prefix}help info, ${prefix}help economy, ${prefix}help transactions, ${prefix}help prophecy, ${prefix}help fun \n For admin commands, run ${prefix}adminhelp`,loc,totell,persid);
  481. } else {
  482. switch(args[1]){
  483. case "info":
  484. case "information":
  485. sendMsg(`Info: ${prefix}vers, ${prefix}help, ${prefix}cooldowns, ${prefix}bal, ${prefix}inv, ${prefix}baltop`,loc,totell,persid);
  486. break;
  487. case "eco":
  488. case "econ":
  489. case "economy":
  490. sendMsg(`Economy: ${prefix}coinflip, ${prefix}work, ${prefix}fish`,loc,totell,persid);
  491. break;
  492. case "money":
  493. case "transactions":
  494. sendMsg(`Transactions: ${prefix}donate, ${prefix}shop, ${prefix}buy, ${prefix}sell `,loc,totell,persid);
  495. break;
  496. case "prophecy":
  497. case "prophetbot":
  498. sendMsg(`Prophecy: ${prefix}how`,loc,totell,persid);
  499. break;
  500. case "fun":
  501. sendMsg(`Fun: ${prefix}paw, ${prefix}claw, ${prefix}kill, ${prefix}choose, ${prefix}rate`,loc,totell,persid);
  502. break;
  503. }
  504. }
  505. break;
  506. // start admin commands
  507. case "adminhelp":
  508. if (admins.indexOf(data.realUsername) == -1) {
  509. return;
  510. }
  511. sendMsg(`${prefix}start, ${prefix}prefix, ${prefix}announce, ${prefix}tellonly, ${prefix}config [option], ${prefix}ban, ${prefix}unban.`)
  512. break;
  513. case "start":
  514. if(admins.indexOf(data.realUsername) != -1) {
  515. if(started) {
  516. sendMsg("Bot has stopped.",loc,totell,persid);
  517. started = false;
  518. } else {
  519. started = true;
  520. sendMsg("Bot has started.",loc,totell,persid);
  521. }
  522. }
  523. break;
  524. case "sentience":
  525. if(admins.indexOf(data.realUsername) != -1) {
  526. sendMsg(`Sentience has been turned ${args[1]}.`,loc,totell,persid);
  527. } else {
  528. sendMsg(`Can't tell me when to be sentient, idiot!`,loc,totell,persid);
  529. }
  530. break;
  531. case "prefix":
  532. if(admins.indexOf(data.realUsername) != -1) {
  533. if(started) {
  534. let prefix = args[1];
  535. botUser = {nick: `Brisbane (${prefix}help)`, color: "#E4B3FF"}
  536. sendMsg(`This bot's new prefix is ${prefix}`,loc,totell,persid)
  537. }
  538. }
  539. break;
  540. case "announce":
  541. if(admins.indexOf(data.realUsername) != -1 && data.dataObj.privateMessage == "to_me") {
  542. let message = args.slice(1).join(" ");
  543. api_chat_send(message, {nick:botUser.nick, color:botUser.color, location:loc});
  544. } else if (admins.indexOf(data.realUsername) != -1) {
  545. api_chat_send(`/tell ${data.id} You have to use /tell with this command.`, {nick:botUser.nick, color:botUser.color, location:loc});
  546. }
  547. break;
  548. case "tellonly":
  549. if(admins.indexOf(data.realUsername) != -1) {
  550. if (tellonly) {
  551. tellonly = false
  552. sendMsg("You don't need to /tell the bot anymore.",loc,NaN,persid);
  553. } else {
  554. sendMsg("Please use /tell to interact with this bot (hover for id).",loc,NaN,persid);
  555. tellonly = true
  556. }
  557. }
  558. break;
  559. case "config":
  560. let option = args[1];
  561. if(admins.indexOf(data.realUsername) != -1) {
  562. let whichone = args[2];
  563. switch(option){
  564. case("cooldown"):
  565. case("cd"):
  566. if (!args[3]) {
  567. cooldowns.general = args[2];
  568. } else {
  569. cooldowns[whichone] = args[3];
  570. }
  571. case("cooldownmultiplier"):
  572. case("cooldownmult"):
  573. case("cdmult"):
  574. if (!args[3]) {
  575. cooldownMults.location.global = args[2];
  576. sendMsg(`Cooldown multiplier for global chat (location.global) has been changed to ${cooldownMults.location.global}x`,loc,totell,persid)
  577. } else {
  578. if (!isNaN(parseInt(args[3]))) cooldownMults[whichone][args[3]] = parseInt(args[4]);
  579. sendMsg(`Cooldown multiplier for ${whichone} ${args[3]} has been changed to ${cooldownMults[whichone][args[3]]}x`,loc,totell,persid)
  580. }
  581. }
  582. }
  583. break;
  584. case "ban":
  585. if(admins.indexOf(data.realUsername) != -1) {
  586. let banvictim = findByName(args[1]);
  587. if (banvictim == undefined) {
  588. sendMsg(`Could not ban ${args[1]}. User does not exist.`,loc,totell,persid);
  589. break;
  590. }
  591. banvictim.banProps.banned = true;
  592. banvictim.banProps.until = args[2] ? unixInSecs() + parseInt(args[2]) : Infinity;
  593. if (args[2]) {
  594. waitUntilUserIsUnbanned(banvictim);
  595. sendMsg(`${banvictim.username} has been banned for ${args[2]} seconds.`,loc,totell,persid);
  596. } else {
  597. sendMsg(`${banvictim.username} has been banned.`,loc,totell,persid);
  598. }
  599. }
  600. break;
  601. case "unban":
  602. let banvictim = findByName(args[1]);
  603. if(admins.indexOf(data.realUsername) != -1) {
  604. unbanUser(banvictim);
  605. sendMsg(`${banvictim.username} has been unbanned.`,loc,totell,persid);
  606. } else if (findByName(banvictim) == person) {
  607. sendMsg(`Bro really thought he could unban himself :skull:`,loc,"to_me",persid);
  608. }
  609. break;
  610. default:
  611. if (universal_cmd_enabled == true) {
  612. var victim = args.slice(1).join(" ");
  613. if (victim == " ") {
  614. sendMsg(`(UNOFFICIAL COMMAND) You must specify someone to ${cmd}.`,loc,totell,persid)
  615. } else {
  616. if(!cmd.endsWith("e")){
  617. sendMsg(`(UNOFFICIAL COMMAND) ${data.nickname || person.name} has ${cmd}ed ${victim}.`,loc,totell,persid)
  618. } else {
  619. sendMsg(`(UNOFFICIAL COMMAND) ${data.nickname || person.name} has ${cmd}d ${victim}.`,loc,totell,persid)
  620. }
  621. }
  622. } else {
  623. break;
  624. }
  625. }
  626. } else if (cmd != undefined && !person.tips.cooldown) {
  627. sendMsg(`To prevent spam, your interactions with Brisbane now have a ${cooldowns.general*cooldownMults.location[data.location]*(cooldownMults.user[person] || 1)}-second cooldown. For lower cooldowns go to ${chatworld}.`,loc,"to_me",persid);
  628. person.tips.cooldown = true;
  629. }
  630. });
  631. // code to handle bans (async)
  632. async function waitUntilUserIsUnbanned(user) {
  633. return await new Promise(resolve => {
  634. const interval = setInterval(() => {
  635. if (user.banProps.until < unixInSecs()) {
  636. clearInterval(interval);
  637. resolve(unbanUser(user));
  638. };
  639. }, 1000);
  640. });
  641. }
  642. function unbanUser(user) {
  643. user.banProps.banned = false;
  644. user.banProps.until = 0;
  645. }
  646. console.log("Started process for bot.");
Advertisement
Comments
Add Comment
Please, Sign In to add comment