super3 / IRC-Bot

A very little basic IRCBot that will get improved over the next time.
http://www.wildphp.com
102 stars 47 forks source link

Add custom exit messages for QUIT #43

Closed oliveratgithub closed 9 years ago

oliveratgithub commented 9 years ago

How about adding customized QUIT-messages to the IRC bot for the Quit & Restart commands?

Probably something like here: https://secure.phabricator.com/D10257

NanoSector commented 9 years ago

I tried to get this to work earlier yesterday, but when I appended a message after the QUIT command it would not get sent to the server (resulting in Client Quit regardless of the message). Does anyone know what the proper syntax is?

oliveratgithub commented 9 years ago

Actually I got it working, it's quite simple. I haven't implemented it yet with a configuration var, but static like this:

1) In Classes > Command > Quit.php:

$this->connection->sendData('QUIT :Shutting down');

[Wildphp@localhost] has quit [Quit: Shutting down]

2) In Classes > Command > Restart.php:

$this->connection->sendData('QUIT :Restarting...');

[Wildphp@localhost] has quit [Quit: Restarting...]

This would be easy to implement with a Config like

$this->connection->sendData('QUIT :' . $config['quit_message']);

But I was too lazy to do it yet ;) Mainly because the Quit-Message is being used for different actions, as you can see above. And I wanted to know, what the bot is doing (quitting is not the same as restarting).

TimTims commented 9 years ago

I'll take a look at it and implement it. As it is a good feature.

NanoSector commented 9 years ago

I'll make a PR later that adds a custom quit message to each per a parameter. I had this before in my local install but it didn't work, turns out I didn't have a : before the message.

TimTims commented 9 years ago

I added a restart message, I'm just going to add a custom version in the config so people can choose their quit message.

NanoSector commented 9 years ago

I've heard that at least Freenode has a timeout set before such messages are accepted. Before that timeout, the generic "Client Quit" message is sent. Keep that in mind while testing.

I'll make a PR later that allows you to pass a message with the Restart and Quit commands.

oliveratgithub commented 9 years ago

Nicely done @Yoshi2889 , I like the solution with listening for optional arguments passed onto the !quit / !restart commands, rather than relying on a default message from the configs.

NanoSector commented 9 years ago

Thanks @oliveratgithub :)