Author Topic: Chat Replacer =help=  (Read 3423 times)

Hi, for my chatbot every time someone says something that I haven't coded a response to yet, I need to open up notepad++, and code it. It gets annoying. I was thinking it would be cool to talk as my bot, so example:

I type in chat: Pandan is cool
It will come out CHATBOT: Pandan is cool

How would I do this?
Re-Define the chat function? I don't think that would be client-sided

code
« Last Edit: October 05, 2013, 12:53:29 PM by Johnny Blockhead »

Parent NMH_Type::Send(%this)

Use %this.setValue(string) and %this.getValue() accordingly

You might want to differentiate between normal chat and chat to use as a chatbot, so with this try typing ^ before every message that should be a chatbot message

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      Parent::Send(%this);
      %text = %this.getValue();
      if(striPos(%text, "^") != -1)
      {
            %nText = "CHATBOT:" @ %text;
            commandToServer('messageSent', %nText);
            return; // don't do anything else if you use a ^ because nobody needs repeated chat messages
      }
   }
};
activatePackage(johnnyPack);

     

You might want to differentiate between normal chat and chat to use as a chatbot, so with this try typing ^ before every message that should be a chatbot message

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      Parent::Send(%this);
      %text = %this.getValue();
      if(striPos(%text, "^") != -1)
      {
            %nText = "CHATBOT:" @ %text;
            commandToServer('messageSent', %nText);
            return; // don't do anything else if you use a ^ because nobody needs repeated chat messages
      }
   }
};
activatePackage(johnnyPack);

That's junk. Because it does not remove the ^, and it detects if there is a ^ anywhere in the message, not just at the beginning.

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      %text = %this.getValue();

      if(getSubStr(%text, 0) $= "^")
      {
            %newText = strReplace(%text, "^", "");
            %newText = "CHATBOT:" SPC %newText;

            %this.setValue(%newText);
      }

      Parent::Send(%this);
   }
};
activatePackage(johnnyPack);
« Last Edit: August 25, 2013, 08:14:13 AM by jes00 »

That's junk. Because it does not remove the ^, and it detects if there is a ^ anywhere in the message, not just at the beginning.

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      %text = %this.getValue();

      if(getSubStr(%text, 0) $= "^")
      {
            %newText = strReplace(%text, "^", "");
            %newText = "CHATBOT:" SPC %newText;

            %this.setValue(%newText);
      }

      Parent::Send(%this);
   }
};
activatePackage(johnnyPack);


That's junk. Because it does remove every ^ in the message.

This one only removes the ^ at the beginning.

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      %text = %this.getValue();

      if(getSubStr(%text, 0) $= "^")
      {
            %newText = getSubStr(%text, 1, striLen(%text)-1);
            %newText = "CHATBOT:"@%newText;

            %this.setValue(%newText);
      }

      Parent::Send(%this);
   }
};
activatePackage(johnnyPack);
« Last Edit: August 26, 2013, 11:31:08 AM by BluetoothBoy »

So many fights

:D


I'll try blue's


Well did it work?
getSubStr(%text, 0)

ofc not

getSubStr(%text, 0,1)

Seems like an awful lot of work when the obvious solution is to just type "CHATBOT: lol i'm an idiot with a chatbot"

Seems like an awful lot of work when the obvious solution is to just type "CHATBOT: lol i'm an idiot with a chatbot"

Pretty dismissive. The guy is trying to make a chatbot and maybe learn more about client and server communication and strings. Chatbots might be annoying, but he's trying to get better and learn something.



Correct me if I'm wrong, but isn't it possible to use


if(striPos(%text, "^") == 0)


in this case?
« Last Edit: August 26, 2013, 08:24:32 PM by {Pacnet2013} »

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      %text = %this.getValue();

      if(getSubStr(%text, 0,1)
      {##
##

            %newText = getSubStr(%text, 1, striLen(%text)-1);
            %newText = "Chatbot:"@%newText;

            %this.setValue(%newText);
      }

      Parent::Send(%this);
   }
};
activatePackage(johnnyPack);

package johnnyPack
{
   function NMH_Type::Send(%this)
   {
      %text = %this.getValue();
      if(strPos(%text,"^")==0)
      {
            %newText = getSubStr(%text, 1, strLen(%text)-1);
            %newText = "Chatbot: "@%newText;
           
            %this.setValue(%newText);
      }

      Parent::Send(%this);
   }
};
activatePackage(johnnyPack);

FTFY

Correct me if I'm wrong, but isn't it possible to use


if(striPos(%text, "^") == 0)


in this case?

Checking whether the first character is that character is a lot more efficient than finding the first occurrence of that character and checking whether or not it is at the beginning.

getSubStr(%text, 0)

ofc not

getSubStr(%text, 0,1)
Woops, lol, didn't even catch that. I just assumed that the rest of the code was ok; my bad... -_-