Skip to content
This repository has been archived by the owner on Sep 26, 2018. It is now read-only.

Reply to Messages Commands

Leonardo Mariscal edited this page Jun 18, 2015 · 3 revisions

You will need the object of the Bot. We will be doing this on the Bot class.

When a message is recived this method will be called, so you will overwrite it

	@Override
	public void onMessage(User user, Channel channel, String message)
	{
		
	}

Here you can check if the sender is a mod or if the message is equals to whathever Complete code:

	@Override
	public void onMessage(User user, Channel channel, String message)
	{
		if (message.equalsIgnoreCase("hello"))
			if (channel.isMod(user))
				this.sendMessage("Hi there Mod " + user, channel);
			else
				this.sendMessage("Hi there " + user, channel);
	}

On IRC the commands usually starts with '!' so I decided to make a method that is called when a command is send
The String command will be get without the starter '!'

	@Override
	public void onCommand(User user, Channel channel, String command)
	{
		if (command.equalsIgnoreCase("hi"))
			this.sendMessage(user + "says: Hi there GUYS!", channel);
	}

Next Topic:

If User is Moderator


Introduction


Medium Stuff


Extra

  • Automatic Messages
  • Custom Commands
  • Coins System

Clone this wiki locally