A custom script that can do multiple things.



  • Hi!

    I asked this in another section of the forums, but I figured that I would have to search the community for assistance.

    I want to do something along the lines of Revlo. Apparently this is not possible to implement and/or create currently, however, I got an idea for a work around that would work for me, but I’m not sure how to do it properly and I’m now seeking your assistance.

    So my idea is, as an example:
    Make a custom command !pushups
    Make a cost for said command (i.e 5000 points).
    Let the !pushups command also activate an audio hook.
    Make the bot whisper me on twitch with the text: “Pushups has been redeemed by (user).”

    This way I’m hearing a sound that the command has been activated and I’m reminded by the whisper once my current game is over, thus remembering to actually fulfill the “request”.

    I have tried to create a custom command and then a custom command audiohook with the same actual comman “!pushups” but once one is created, the other function won’t work.
    I then figured that I can just add a cost to an audio hook custom command.
    From there I just need to figure out, how to make the bot whisper me with said info above, when the lines of commands I select are activated.

    And it would be nice if I could make the bot respond something along the lines of:
    "(user) has just used (points) on 10 pushups for, EchersDK."
    once the specific commands I choose are activated.

    I hope you can help.

    Thanks! :)



  • @EchersDK said in A custom script that can do multiple things.:

    (user) has just used (points) on 10 pushups for, EchersDK.

    I can write this out for you in about 5 minutes or so.

    Question:

    Do you want the amount of pushups to be set by the user, or set by you?

    If set by you, it can be a variable in the database and changed by commands, and the command cost would be a flat fee (Also set by you).

    If not, the command price would start at X (X being defined by you), and then for every additional pushup, it would increase by X.

    Examples:

    Username: !pushups
    Bot: Username has just used 5000 points on 10 pushups for, EchersDK."
    ^In this case, the pushups command costs 5000 points.

    OR
    Username: !pushups 10
    Bot: Username has just used 5000 points on 10 pushups for, EchersDK."
    ^In this case, the command costs 500 points.


  • Bot Developer

    possible to make the command but the whisper part is difficult. What you could do is have it only whisper and it will the user of the command will know that the command went through thanks to the audio hook.



  • @UsernamesSuck
    It would actually be nice to have the possibility to let the user choose the amount of pushups, however, I can’t take more than 10, hah!

    But in that case, it could just be multiplied. So that every number above 10 would multiply by 1.5-ish.

    Now for my next issue for this. I need multiple commands that does this sort of thing.
    So it would have to be created for multiple commands.

    On top of that I forgot to mention that, I would need the feature from Revlo, that let’s me upload a .csv file with a bunch of CD Keys that people can buy for a certain amount of points - Currently 15.000 for random and 20.000 for a premium key.

    So in that case I would need the bot to whisper users who buy a key from the .csv file and then ‘delete/forget’ that specific key just given out, so it won’t give it out again by mistake… Makes sense?

    I hope I come across understandable. I’m having a hard time explaining it in english.

    But thanks so far! :)



  • @EchersDK

    With one post you changed a 5 minute script into something that could take a couple hours or longer (depending on skill, and the bot).

    It would actually be nice to have the possibility to let the user choose the amount of pushups, however, I can’t take more than 10, hah!

    But in that case, it could just be multiplied. So that every number above 10 would multiply by 1.5-ish.

    That’s not hard to accomplish.

    If(user input greater than 1) {
    price = ((price for 10 pushups * 1.5) * (user input subtract 1)); // the 1 is auto-taken by the bot
    } // This is not genuine code, do not try using it for anything ever.

    Now for my next issue for this. I need multiple commands that does this sort of thing.
    So it would have to be created for multiple commands.

    Use aliases. If the commands do the exact same thing, why bother making the exact same command? Just reference the existing. Unless you expect them to do something not the same…

    On top of that I forgot to mention that, I would need the feature from Revlo, that let’s me upload a .csv file with a bunch of CD Keys that people can buy for a certain amount of points - Currently 15.000 for random and 20.000 for a premium key.

    You could potentially load the file (it would be better if it was plaintext, but iirc java can read csv files okay) on bot startup and then have a command to re-load it if you altered it (Note: Best to restart the bot if altering a file it is using. The bot loads files in memory and editing it while it’s accessed can cause issues).

    This, however, would mean you need to include a database of “used keys” and to make sure that you never give out a duplicate. You would also have to ensure that a user doesn’t redeem the reward without there being a valid key to use.

    So in that case I would need the bot to whisper users who buy a key from the .csv file and then ‘delete/forget’ that specific key just given out, so it won’t give it out again by mistake… Makes sense?

    The problem with whispers is it uses the same global chat timer as any other message your bot would send. This would add a delay to anyone in chat using other functions of the bot and expecting a return message.



  • @UsernamesSuck So basically, some of it is easily achievable, and other stuff is quite hard to make. In order for it to work properly that is.

    I think for now, I’ll stick with having RevloBot and just disable the points system in PhantomBot :)

    I really appreciate your time and I’ve saved all the info, so that if I decide to move forward with my idea, I’ll do so at a later point. But I can’t even wrap my own head around this. I just know what I need for the final result, but as for right now, I don’t understand much of what is in between.

    Like I understand this:
    If(user input greater than 1) {
    price = ((price for 10 pushups * 1.5) * (user input subtract 1)); // the 1 is auto-taken by the bot
    } // This is not genuine code, do not try using it for anything ever.

    And the aliases too, but that’s about it. And how I would go about making the bot load that csv file and output a key to a specific user (again, as a whisper), is beyond my understanding.

    But again, I really appreciate taking you time to read my idea and provide me with possible solutions. But it would end up being much more… Time consuming that I first thought… And RevloBot is quite simple as well.

    I only wanted it in PhantomBot in order to keep everything in one bot, but for now that won’t be possible, with my really low-end skillset :P



  • @EchersDK

    It’s simple for RevloBot because that’s exactly what it was designed for… They built the bot around points, contests, rewards, and giveaways. That’s why it has very little other functions. RevloBot can’t moderate your chat, say custom commands, or any of the fun stuff that you see in PhantomBot, or really any other bot.

    And how I would go about making the bot load that csv file and output a key to a specific user (again, as a whisper), is beyond my understanding.

    See, the awesome thing about PhantomBot (Compared to most others) is that it’s open source. So all you have to do is dig around the code for what you need (most of the time). For instance, the Youtube Player within the bot can load a text file when you do the command “!playlist importpl file <filename> <playlist>”.

    So what you want to do is analyze that code, and find out how it’s loading the file:

                if ($.fileExists("./addons/youtubePlayer/" + fileName)) {
                    $.say($.whisperPrefix(sender) + $.lang.get('ytplayer.command.importpl.file.start'));
                    importedList = readFile("./addons/youtubePlayer/" + fileName);
                    for (var i = 0; i < importedList.length; i++) {
                        if (importedList[i].contains('&list')) {
                            playlistFailCount++;
                            continue;
                         }
    
                        try {
                            var youtubeVideo = new YoutubeVideo(importedList[i], 'importPlaylistFile');
                            $.inidb.set(playlistDbPrefix + listName, importCount, youtubeVideo.getVideoId());
                            importCount++;
                        } catch (ex) {
                            $.log.error("importPlaylistFile::skipped [" + importedList[i] + "]: " + ex);
                            failCount++;
                        }
                        if (importCount >= 150) {
                            break;
                        }
                    }
                    $.inidb.set(playlistDbPrefix + listName, 'lastkey', importCount);
    
                    if (playlistFailCount > 0) {
                        return $.lang.get('ytplayer.command.importpl.file.success.plerror', importCount, failCount, fileName, listName, playlistFailCount);
                    } else {
                        return $.lang.get('ytplayer.command.importpl.file.success', importCount, failCount, fileName, listName);
                    }
                } else {
                    return $.lang.get('ytplayer.command.importpl.file.404', fileName);
                }
    

    And here it is. Now there’s a lot of “junk” in that code you can ignore, because it’s mostly safety-checks for Youtube and whatnot.

    The bit you really want out of it would be:

            if ($.fileExists("./addons/youtubePlayer/" + fileName)) {// Verifies the file exists. Change this to your .csv
                importedList = readFile("./addons/youtubePlayer/" + fileName);// This loads the file to be read line by line. Again, change to your .csv
                for (var i = 0; i < importedList.length; i++) {// This is the for loop that handles reading every individual line
                            $.inidb.set(playlistDbPrefix + listName, importCount, youtubeVideo.getVideoId());// Adds the data into the database. You want to change 'playlistDbPrefix + listName' to your reward database name. Change 'importCount' to i. And change 'youtubeVideo.getVideoId()' to importedList[i] . Note: You will want to do your checks here, such as if the key already exists, or if it is in the "Used-key" database, as you don't want to import those. You also want to make sure you're not adding a blank/empty line into the database.
                }
            } else {
                return $.lang.get('ytplayer.command.importpl.file.404', fileName);// Just add in a  "Hey the file you listed doesn't exist" message here.
            }


  • @UsernamesSuck You are absolutely right, but it would take me longer than I would be able to spend on it at this point.
    I will however, dig into this and I also saved the last lines you sent too.

    I need a couple of hours to even just sit down and properly explain myself in english how I really wanted/needed the bot to work.
    I mean, there is work-arounds, but I’d like to do it properly the first time ;).

    But I really appreciate your assistance!


Log in to reply
 

Looks like your connection to PhantomBot Community Forums was lost, please wait while we try to reconnect.