Advertisement
Slowstone72

Auto Fisher for Multiplayer Piano's Fishing

Dec 1st, 2024 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 7.43 KB | Software | 0 0
  1. /* "Auto Fisher (hah) for Multiplayer Piano's 'Fishing' bot"
  2. 2024.01.16 - 2024.11.29
  3.  
  4. Callum Fisher <cf.fisher.bham@gmail.com>
  5.  
  6. This is free and unencumbered software released into the public domain.
  7.  
  8. Anyone is free to copy, modify, publish, use, compile, sell, or
  9. distribute this software, either in source code form or as a compiled
  10. binary, for any purpose, commercial or non-commercial, and by any
  11. means.
  12.  
  13. In jurisdictions that recognize copyright laws, the author or authors
  14. of this software dedicate any and all copyright interest in the
  15. software to the public domain. We make this dedication for the benefit
  16. of the public at large and to the detriment of our heirs and
  17. successors. We intend this dedication to be an overt act of
  18. relinquishment in perpetuity of all present and future rights to this
  19. software under copyright law.
  20.  
  21. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  24. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  25. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  26. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  27. OTHER DEALINGS IN THE SOFTWARE.
  28.  
  29. For more information, please refer to <https://unlicense.org/> */
  30.  
  31. let autoFisher = {
  32.     lastMessage: '',
  33.     chatQueue: [],
  34.     functions: {
  35.         advanceChatQueue: () => {
  36.             let msg = autoFisher.chatQueue.splice(0, 1)[0];
  37.             MPP.client.sendArray([{
  38.                 m: 'a',
  39.                 message: msg
  40.             }]);
  41.         },
  42.         qMsg: (msg, bypass, dmID) => {
  43.             if (typeof msg !== 'string') msg = JSON.stringify(msg);
  44.             if (dmID) {
  45.                 MPP.client.sendArray([{
  46.                     m: 'dm',
  47.                     _id: dmID,
  48.                     message: msg
  49.                 }]);
  50.                 return;
  51.             }
  52.             if (autoFisher.lastMessage !== msg || bypass) {
  53.                 msg.match(/.{0,511}/g).forEach((x, i) => {
  54.                     if (x == '') return;
  55.                     if (i !== 0) x = '...' + x;
  56.                     autoFisher.chatQueue.push(x.trim());
  57.                 });
  58.                 autoFisher.lastMessage = msg;
  59.             }
  60.         },
  61.         handleMessage: msg => {
  62.             // console.log(msg.p._id + ' ' + autoFisher.fishingBotID);
  63.             if (msg.p._id !== autoFisher.fishingBotID) return;
  64.             // console.log(msg.a)
  65.             if (msg.a.startsWith(`͏Our good friend ${autoFisher.myName} caught`) || msg.a.includes(`@${autoFisher.myID} caught`)) {
  66.                 autoFisher.isWaitingForFish = false;
  67.             }
  68.             if (msg.a.startsWith(`͏Our friend ${autoFisher.myName} is getting a bite`) || msg.a.startsWith(`͏Our friend @${autoFisher.myID} is getting a bite`)) {
  69.                 autoFisher.functions.startFishing();
  70.             }
  71.             if (msg.a.startsWith(`͏Contents of ${autoFisher.myName}'s fish sack:`)) {
  72.                let sack = msg.a.split(`Contents of ${autoFisher.myName}'s fish sack:`)[1].trim();
  73.                 // console.log(sack);
  74.                 if (sack.includes('kekklefruit')) {
  75.                     if (Date.now().valueOf() - autoFisher.lastEatKekkleFruit > 240000) {
  76.                         autoFisher.lastEatKekkleFruit = Date.now().valueOf();
  77.                         autoFisher.functions.qMsg('/eat kekklefruit');
  78.                     }
  79.                 }
  80.             }
  81.             // For Hri7566's Fishing:
  82.             if (msg.a.startsWith(`͏Contents of ${autoFisher.myName}'s inventory`)) {
  83.                let sack = msg.a.split(`͏Contents of ${autoFisher.myName}'s inventory:`)[1].trim();
  84.                 // console.log(sack);
  85.                 if (sack.includes('Kekklefruit')) {
  86.                     if (Date.now().valueOf() - autoFisher.lastEatKekkleFruit > 240000) {
  87.                         autoFisher.lastEatKekkleFruit = Date.now().valueOf();
  88.                         autoFisher.functions.qMsg('/eat kekklefruit');
  89.                     }
  90.                 }
  91.             }
  92.             if (msg.a.startsWith(`͏Friend ${autoFisher.myName}:`)) {
  93.                 let treeCount = Number(msg.a.split(`Friend ${autoFisher.myName}:`)[1].trim());
  94.                 if (!isNaN(treeCount)) {
  95.                     if (treeCount > 0) {
  96.                         for (var i = 0; i < Math.ceil(treeCount / 2); i++) {
  97.                             autoFisher.functions.qMsg('/pick', true);
  98.                         }
  99.                         autoFisher.functions.qMsg('/eat kekklefruit');
  100.                     }
  101.                 }
  102.             }
  103.         },
  104.         startFishing: successMessage => {
  105.             autoFisher.isWaitingForFish = true;
  106.             if (successMessage && Math.random() < 0.20) autoFisher.functions.qMsg(autoFisher.functions.rando(autoFisher.successMessages));
  107.             if (!successMessage) autoFisher.functions.qMsg(autoFisher.functions.rando(autoFisher.failureMessages));
  108.             setTimeout(() => {
  109.                 autoFisher.functions.qMsg('/fish', true);
  110.             }, autoFisher.functions.randomNum(0, 10000));
  111.         },
  112.         rando: array => {
  113.             return Array.isArray(array) || (array = Array.from(arguments)), array[Math.floor(Math.random() * array.length)];
  114.         },
  115.         randomNum: (min, max) => {
  116.             return min + (Math.random() * (max - min));
  117.         }
  118.     },
  119.     successMessages: [
  120.         'Very good',
  121.         'Uh huh, very good',
  122.         'veeeery good',
  123.         'Very, very good',
  124.         'Yes - Very good.',
  125.         'uh huh',
  126.         'fish.',
  127.         'Good',
  128.         'Mhmmmmmm'
  129.     ],
  130.     failureMessages: [
  131.         'This is not very good',
  132.         'Not good...',
  133.         'Very bad...',
  134.         'Bad...'
  135.     ],
  136.     myName: MPP.client.getOwnParticipant().name,
  137.     myID: MPP.client.getOwnParticipant()._id,
  138.     fishingBotID: '8107156a27514cebcb65195d',
  139.     doFishing: true,
  140.     isWaitingForFish: false,
  141.     checkTreeEveryXFish: 20,
  142.     checkTreeCount: 0,
  143.     donateFishEveryXFish: 20,
  144.     donateFishCount: 0,
  145.     checkSackEveryXFish: 10,
  146.     checkSackCount: 0,
  147.     lastEatKekkleFruit: 0,
  148.     mainInterval: setInterval(() => {
  149.         if (autoFisher.chatQueue.length > 0) autoFisher.functions.advanceChatQueue();
  150.         // Check tree:
  151.         if (autoFisher.checkTreeCount >= autoFisher.checkTreeEveryXFish) {
  152.             autoFisher.checkTreeCount = 0;
  153.             autoFisher.functions.qMsg('/tree', true);
  154.         }
  155.         // Danate fish:
  156.         if (autoFisher.donateFishCount >= autoFisher.donateFishEveryXFish) {
  157.             autoFisher.donateFishCount = 0;
  158.             let ppl = MPP.client.ppl;
  159.             let person = autoFisher.functions.rando(Object.keys(ppl).filter(user => (ppl[user].tag ? ppl[user].tag.text !== 'BOT' : true) && ppl[user]._id !== autoFisher.myID));
  160.             autoFisher.functions.qMsg(`/give ${ppl[person].name.split(' ')[0]}`, true);
  161.         }
  162.         // Check sack:
  163.         if (autoFisher.checkSackCount >= autoFisher.checkSackEveryXFish) {
  164.             autoFisher.checkSackCount = 0;
  165.             autoFisher.functions.qMsg('/sack');
  166.             autoFisher.functions.qMsg('/inventory');
  167.         }
  168.         if (!autoFisher.doFishing || autoFisher.isWaitingForFish) return;
  169.         // Caught a fish:
  170.         autoFisher.functions.startFishing(true);
  171.         autoFisher.checkTreeCount ++;
  172.         autoFisher.donateFishCount ++;
  173.         autoFisher.checkSackCount ++;
  174.     }, 2000)
  175. }
  176.  
  177. MPP.client.on('a', autoFisher.functions.handleMessage);
  178.  
  179. // ppl = Object.keys(ppl).filter(user => ppl[user].tag ? ppl[user].tag.text !== 'BOT' : true).length;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement