GIF Alerts with custom text




I’m 100% sure there are better ways to do it and that I did it in a completely non-optimal way, but well, I got inspired from the tts !shout command posted here in the forums and sorted some tricks with jQuery (I know 0 about javascript/jQuery/css)

For this to work you have to edit the original alertHandler.js though, so you would have to re-add the lines at every phantombot update (I’ve got no clue in how I could implement this without editing it)

I added comments on the custom script that explain what to edit if you want a different outcome and a copy of what should be added to the alertHandler file. The default new command is “!1v1” to trigger the default banana gif and the sender’s name below. You can customize it to do pretty much what you want, I just don’t know how so I kept it minimal ahahahaha

Add “OnevOneSystem.js” to “botfolder\scripts\custom” (create the folder if it doesn’t exist) and add these lines to the “alertHandler.js” file in “botfolder\web\alerts\js” above line 108/above line that says:

imageFileBasename = imageFile.substring(0, imageFile.indexOf(’.’));

   if (imageFile.substring(0,5) == "<1v1>"){ // Check if it's an 1v1 alert.
  	var textToShow = imageFile.substring(5); // Variable without "<1v1>"
  	var duration1v1 = duration;
  	// Creates a new div and sets the text
  	$('body').append("<div id=\"textLocation\" style=\"display:block; color:red; width: 100%; text-align: center; opacity: 0; margin-top: 30px;\" </div>");
  	$('#textLocation').css('font-family', 'Impact');
  	$('#textLocation').css('font-size', '40px');
  	$('#textLocation').text(textToShow + " MI SFIDA A DUELLO!").fadeTo(1000, 1);
  	// Deletes the text, the new div and the temporary css styles from the html after a timeout
  	setTimeout(function() { $('#textLocation').fadeOut(1000),
  							$('#imageLocation').fadeOut(1000); }, duration1v1);
  	setTimeout(function() { $('#textLocation').remove(),
  							$('#imageLocation').css('justify-content', ''); }, duration1v1 + 1000);

OnevOneSystem.js (2.3 KB)

Oh, please tell me if you know any better way to do this, I’d really like to see a solid implementation of text in phantombot alerts system without all the mess I did


Hey I made some modifications to your code, but everything should work the exact same.



only 1 issue with this… if someone else uses something that triggers the alerts then it doesnt add it to a queue it just overrides it from the start… any way to make it add to a queue so it can only do 1 every 5 seconds


The overriding of the alerts was something I thought later but I really have no clue in how i could implement a queue for this


Yes take a look at how followHandler.js handles it’s system.

    var followQueue = new java.util.concurrent.ConcurrentLinkedQueue;// initialize queue

        followQueue.add(s);// add to queue

    if (!followQueue.isEmpty() && (lastFollow + (followDelay * 1e3)) < $.systemTime()) {// sending
        lastFollow = $.systemTime();

The “sending” code is on a timer.