Results 1 to 10 of 10
  1. #1
    kiwi5's Avatar
    Join Date
    Feb 2016
    Gender
    male
    Location
    Puerto Rico
    Posts
    2,025
    Reputation
    713
    Thanks
    3,449
    My Mood
    Sad

    [N-Relay] Daily Collector

    Collects the available awards for your account(s).

    Code:
    import { ClaimDailyRewardMessage } from '../networking/packets/outgoing/claim-daily-reward-message';
    import { GoToQuestRoomPacket } from '../networking/packets/outgoing/go-to-quest-room-packet';
    import { Http } from '../services/http';
    import { Client, Log, LogLevel, NrPlugin } from './../core/plugin-module';
    
    const KEY_REGEX = /<key>(\w+)<\/key>/g;
    
     @NRPlugin({
        name: 'Collector',
        author: 'tcrane+kiwi5',
        enabled: true
    })
    class CollectorPlugin {
        constructor() {
            Client.on('ready', (pd, client: Client) => {
                if (client.mapInfo.name === 'Nexus') {
                    Log('Collector', `Sending ${client.alias} to quest room`);
                    const gotoQuestRoom = new GoToQuestRoomPacket();
                    client.packetio.sendPacket(gotoQuestRoom);
                } else {
                    Log('Collector', `Fetching calendar for ${client.alias}`);
                    Http.get('https://realmofthemadgodhrd.appspo*****m/dailyLogin/fetchCalendar', {
                        guid: client.guid,
                        password: client.password
                    }).then((response) => {
                        Log('Collector', `Received calendar for ${client.alias}`, LogLevel.Success);
                        const items = this.getKeys(response);
                        if (items.length === 0) {
                            Log('Collector', `Nothing to collect for ${client.alias}!`, LogLevel.Success);
                        } else {
                            Log('Collector', `Collecting ${items.length} item${items.length === 1 ? '' : 's'} for ${client.alias}`);
                            this.collect(items, client)
                                .then(() => Log('Collector', `Finished collecting items for ${client.alias}!`, LogLevel.Success));
                        }
                    }).catch((error) => {
                        Log('Collector', `Error fetching calendar for ${client.alias}`);
                        Log('Collector', error.message, LogLevel.Warning);
                    });
                }
            });
        }
    
        private getKeys(xml: string): string[] {
            const items: string[] = [];
            let match = KEY_REGEX.exec(xml);
            while (match !== null) {
                items.push(match[1]);
                match = KEY_REGEX.exec(xml);
            }
            return items;
        }
    
        private collect(collectables: string[], client: Client): Promise<void> {
            return new Promise((resolve, reject) => {
                const collect = (item: string) => {
                    Log('Collector', `Collecting item(s) for ${client.alias}`, LogLevel.Info);
                    const claim = new ClaimDailyRewardMessage();
                    claim.claimKey = item;
                    claim.claimType = 'nonconsecutive';
                    client.packetio.sendPacket(claim);
                    if (collectables.length > 0) {
                        setTimeout(() => {
                            collect(collectables.shift());
                        }, 1500);
                    } else {
                        resolve();
                    }
                };
                collect(collectables.shift());
            });
        }
    }
    Creds:
    @059
    @Killer Be Killed
    @kiwi5

  2. The Following 6 Users Say Thank You to kiwi5 For This Useful Post:

    001. (07-22-2018),Alde. (05-02-2020),ArkMods (07-23-2018),DevilRotMG (07-22-2018),headlesspiranha (07-22-2018),Killer Be Killed (07-23-2018)

  3. #2
    DevilRotMG's Avatar
    Join Date
    Jun 2018
    Gender
    male
    Location
    Dust II
    Posts
    364
    Reputation
    -3
    Thanks
    155
    My Mood
    Drunk
    Nice contribution. +Rep.

  4. The Following User Says Thank You to DevilRotMG For This Useful Post:

    kiwi5 (07-22-2018)

  5. #3
    Killer Be Killed's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    212
    Reputation
    53
    Thanks
    2,352
    My Mood
    Asleep
    Please be aware that this will only work with the latest version (6.20.0), as the client's password property was private prior to this version.

  6. The Following User Says Thank You to Killer Be Killed For This Useful Post:

    kiwi5 (07-23-2018)

  7. #4
    hokko's Avatar
    Join Date
    Nov 2012
    Gender
    male
    Location
    Epic 2818
    Posts
    1,291
    Reputation
    85
    Thanks
    57
    Completely noob.
    Where should I put this file?
    What are the names of these file?
    How to run?
    @headlesspiranha

    I got error:
    src\plugins\daily_collector.ts(8,3): error TS2552: Cannot find name 'NRPlugin'. Did you mean 'Plugin'?

  8. #5
    headlesspiranha's Avatar
    Join Date
    Mar 2018
    Gender
    male
    Posts
    56
    Reputation
    16
    Thanks
    17
    Quote Originally Posted by hokko View Post
    Completely noob.
    Where should I put this file?
    What are the names of these file?
    How to run?
    @headlesspiranha
    For future reference,

    You can name a file whatever you want, but I prefer to keep it similar to what the plugin does - for this specific plugin I just named mine daily-collector.ts, but it is your choice.

    All plugin files go under \nrelay\src\plugins, with this plugin you need to change:
    Code:
    Change (Line 8): NRPlugin to NrPlugin,
    Change (Line 23): https to http

  9. The Following User Says Thank You to headlesspiranha For This Useful Post:

    hokko (08-15-2018)

  10. #6
    hokko's Avatar
    Join Date
    Nov 2012
    Gender
    male
    Location
    Epic 2818
    Posts
    1,291
    Reputation
    85
    Thanks
    57
    Quote Originally Posted by headlesspiranha View Post
    For future reference,

    You can name a file whatever you want, but I prefer to keep it similar to what the plugin does - for this specific plugin I just named mine daily-collector.ts, but it is your choice.

    All plugin files go under \nrelay\src\plugins, with this plugin you need to change:
    Code:
    Change (Line 8): NRPlugin to NrPlugin,
    Change (Line 23): https to http
    when I type nrelay , I got this:
    bash: nrelay: command not found

  11. #7
    headlesspiranha's Avatar
    Join Date
    Mar 2018
    Gender
    male
    Posts
    56
    Reputation
    16
    Thanks
    17
    Quote Originally Posted by hokko View Post
    when I type nrelay , I got this:
    bash: nrelay: command not found
    Follow the tutorial setup from /thomas-crane/nrelay @ ******

  12. #8

  13. #9
    setecby's Avatar
    Join Date
    Jan 2019
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0

    Updated version

    Here is a version which works with latest nrelay. I've disabled tslint, by removing tslint.json, so this script may require some formatting if you are still using that retarded shit called tslint

    Code:
    import { ClaimDailyRewardMessage } from '../networking/packets/outgoing/claim-daily-reward-message';
    import { GoToQuestRoomPacket } from '../networking/packets/outgoing/go-to-quest-room-packet';
    import { HttpClient } from '../services/http';
    import {Library} from "../decorators/library";
    import {LogLevel} from "../services/logger";
    import {Logger} from "../services/logger";
    import {Client} from "../core";
    
    const KEY_REGEX = /<key>(\w+)<\/key>/g;
    
      @Library({
      name: 'Collector',
      author: 'tcrane+kiwi5',
      enabled: true
    })
    class CollectorPlugin {
      constructor() {
        Client.on('ready', (client: Client) => {
          if (client.mapInfo.name === 'Nexus') {
            Logger.log('Collector', `Sending ${client.alias} to quest room`);
            const gotoQuestRoom = new GoToQuestRoomPacket();
            client.packetio.sendPacket(gotoQuestRoom);
          } else {
            Logger.log('Collector', `Fetching calendar for ${client.alias}`);
            HttpClient.get('https://realmofthemadgodhrd.appspo*****m/dailyLogin/fetchCalendar', { query: {
              guid: client.guid,
              password: client.password
            }})
              .then((response:any) => {
              Logger.log('Collector', `Received calendar for ${client.alias}`, LogLevel.Success);
              const items = this.getKeys(response);
              if (items.length === 0) {
                Logger.log('Collector', `Nothing to collect for ${client.alias}!`, LogLevel.Success);
              } else {
                Logger.log('Collector', `Collecting ${items.length} item${items.length === 1 ? '' : 's'} for ${client.alias}`);
                this.collect(items, client)
                  .then(() => Logger.log('Collector', `Finished collecting items for ${client.alias}!`, LogLevel.Success));
              }
            }).catch((error:any) => {
              Logger.log('Collector', `Error fetching calendar for ${client.alias}`);
              Logger.log('Collector', error.message, LogLevel.Warning);
            });
          }
        });
      }
    
      private getKeys(xml: string): string[] {
        const items: string[] = [];
        let match = KEY_REGEX.exec(xml);
        while (match !== null) {
          items.push(match[1]);
          match = KEY_REGEX.exec(xml);
        }
        return items;
      }
    
      private collect(collectables: string[], client: Client): Promise<void> {
        return new Promise((resolve, reject) => {
          const collect = (item: string) => {
            Logger.log('Collector', `Collecting item(s) for ${client.alias}`, LogLevel.Info);
            const claim = new ClaimDailyRewardMessage();
            claim.claimKey = item;
            claim.claimType = 'nonconsecutive';
            client.packetio.sendPacket(claim);
            if (collectables.length > 0) {
              setTimeout(() => {
                collect(collectables.shift());
              }, 1500);
            } else {
              resolve();
            }
          };
          collect(collectables.shift());
        });
      }
    }
    Last edited by setecby; 08-12-2019 at 06:14 AM.

  14. #10
    dudeguy1337's Avatar
    Join Date
    Apr 2020
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    1

    Cool Updated nrelay v8

    Yo my dudes,

    Here's an updated TS script which works with the lastest version of nrelay.
    Also, merged some changes from thread 1392628 which makes retrieving rewards less error prone.

    Code:
    import {
      Client,
      Library,
      Runtime,
      Events,
      Logger,
      LogLevel,
      HttpClient,
      GoToQuestRoomPacket,
      ClaimDailyRewardMessage
    } from 'nrelay';
    
      @Library({
      name: 'Auto claim daily rewards',
      author: 'tcrane, kiwi5, headlesspiranha, d00dguy1337',
      enabled: true
    })
    
    class CollectorPlugin {
      constructor(runtime: Runtime) {
        runtime.on(Events.ClientReady, (client: Client) => {
          switch(client.mapInfo.name) {
            case 'Nexus':
              this.GoToQuestRoom(client);
              break;
            case 'Daily Quest Room':
              this.ClaimDailyRewards(client);
              break;
            default:
              Logger.log('Collector', `Unknown map ${client.mapInfo.name}!`, LogLevel.Error);
              this.logOut(client);
          };
        });
      }
    
      private GoToQuestRoom(client: Client) {
        Logger.log('Collector', `Sending ${client.alias} to quest room...`);
        const gotoQuestRoom = new GoToQuestRoomPacket();
        client.io.send(gotoQuestRoom);
      }
    
      private ClaimDailyRewards(client: Client) {
        Logger.log('Collector', `Fetching calendar for ${client.alias}...`);
        HttpClient
          .get('https://realmofthemadgodhrd.appspo*****m/dailyLogin/fetchCalendar', {
            query: {
              guid: client.guid,
              password: client.password
            }
          })
          .then((response) => {
            const items = this.getKeys(response);
            if (items.length === 0) {
              Logger.log('Collector', `Nothing to collect for ${client.alias}!`);
              this.logOut(client);
            } else {
              Logger.log('Collector', `Collecting ${items.length} item${items.length === 1 ? '' : 's'} for ${client.alias}`);
              this
                .collect(items, client)
                .then(() => {
                  Logger.log('Collector', `Finished collecting items for ${client.alias}!`)
                  setTimeout(() => this.logOut(client), 2000);
                });
    
            }
          })
          .catch((error) => {
            Logger.log('Collector', `Error fetching calendar for ${client.alias}!`);
            Logger.log('Collector', error.message, LogLevel.Error);
            this.logOut(client);
          });
      }
    
      private logOut(client: Client) {
        Logger.log('Collector', `Loging out ${client.alias}`);
        client.destroy();
      }
    
      private getKeys(xml: string): string[] {
        const items: string[] = [];
    
        const parseString = require("xml2js").parseString;
        parseString(xml,
          {
            mergeAttrs: true,
            trim: true,
            explicitArray: false
          },
          function (err: any, result: any) {
            const json = JSON.stringify(result);
            const parsedJson = JSON.parse(json);
            for (const loginReward of parsedJson.LoginRewards.NonConsecutive.Login) {
              if (loginReward.key) {
                items.push(loginReward.key);
              }
            }
          }
        );
    
        return items;
      }
    
      private collect(collectables: string[], client: Client): Promise<void> {
        return new Promise((resolve, reject) => {
          const collect = (item: string) => {
            const claim = new ClaimDailyRewardMessage();
            claim.claimKey = item;
            claim.claimType = 'nonconsecutive';
            client.io.send(claim);
            if (collectables.length > 0) {
              setTimeout(() => {
                collect(collectables.shift());
              }, 1500);
            } else {
              resolve();
            }
          };
          collect(collectables.shift());
        });
      }
    }
    Also, change your versions.json with the following (as the updater fails to update it correctly to this day)
    Code:
    {
      "assetVersion": "1587115536",
      "clientVersion": "1587115536",
      "buildVersion": "X33.0.1",
      "clientToken": "XTeP7hERdchV5jrBZEYNebAqDPU6tKU6"
    }
    Now, to build and all
    - npm i xml2js
    - nrelay build
    - nrelay run --update-from=AssembleeGameClient1587115536.swf --force-update

    Here AssembleeGameClient1587115536 is the latest SWF (to this day) which you can get from the realmofthemadgod website.

    Now you can for the subsequent runs just do
    - nrelay run
    Last edited by dudeguy1337; 05-02-2020 at 04:22 AM. Reason: added timeout after "Finished collecting items" because when disconnect so fast some claims dont register.

  15. The Following User Says Thank You to dudeguy1337 For This Useful Post:

    glanhead (06-23-2020)

Similar Threads

  1. AHK Daily Login Collector
    By 09morbab in forum Realm of the Mad God Hacks & Cheats
    Replies: 19
    Last Post: 07-13-2018, 09:55 AM
  2. [Release] Simple Daily Login Reward Collector
    By Natiiix in forum Realm of the Mad God Hacks & Cheats
    Replies: 28
    Last Post: 07-03-2018, 03:31 AM
  3. [Outdated] AHK Daily Login Collector
    By 09morbab in forum Realm of the Mad God Hacks & Cheats
    Replies: 4
    Last Post: 04-26-2018, 01:56 PM
  4. [Release] K Relay Plugin: Daily Quest
    By Plann in forum Realm of the Mad God Hacks & Cheats
    Replies: 24
    Last Post: 08-19-2015, 10:42 AM
  5. The Daily Show
    By Chronologix in forum Entertainment
    Replies: 2
    Last Post: 01-19-2006, 03:20 PM