diff --git a/BOT.php b/BOT.php index ceef755..9a3946c 100644 --- a/BOT.php +++ b/BOT.php @@ -1,6 +1,7 @@ !seen */ break; - - } +} /* CTCP */ if($GLOBALS['C_CTCP_RESPONSE'] == 'yes') { @@ -387,6 +388,17 @@ function Engine() } } //------------------------------------------------------------------------------------------------ +function msg_without_command() +{ + $input = NULL; + for($i=3; $i <= (count($GLOBALS['ex'])); $i++) { $input .= $GLOBALS['ex'][$i]." "; } + + $in = rtrim($input); + $data = str_replace($GLOBALS['rawcmd'][1].' ', '', $in); + + return $data; +} +//------------------------------------------------------------------------------------------------ function HasAccess($mask) { global $admins; diff --git a/CONFIG.INI b/CONFIG.INI index 79839c0..0816efa 100644 --- a/CONFIG.INI +++ b/CONFIG.INI @@ -27,7 +27,7 @@ command_prefix = '!' [CTCP] ctcp_response = 'yes' -ctcp_version = 'davybot (0.3.0)' +ctcp_version = 'davybot (0.3.1)' ctcp_finger = 'davybot' [FETCH] diff --git a/DOCS/CHANGELOG.TXT b/DOCS/CHANGELOG.TXT index 025115c..648ab07 100644 --- a/DOCS/CHANGELOG.TXT +++ b/DOCS/CHANGELOG.TXT @@ -1,4 +1,10 @@ + v0.3.1 changes (29.08.2017): + - corrected start time + - new plugin: !winamp - you can now control winamp by bot :) + - save plugin code cleanup + - topic plugin bug fixed + v0.3.0 changes (25.08.2017): - changed from 'password' to -> 'register ' - new plugin: !weather -- Shows actual weather: !weather diff --git a/PLUGINS/save.php b/PLUGINS/save.php index 997e1a4..95ebeff 100644 --- a/PLUGINS/save.php +++ b/PLUGINS/save.php @@ -7,12 +7,13 @@ function plugin_save() { - if(empty($GLOBALS['args'])) { CHANNEL_MSG('Usage: '.$GLOBALS['C_CMD_PREFIX'].'save help to list commands'); } + if(empty($GLOBALS['args'])) { CHANNEL_MSG('Usage: '.$GLOBALS['C_CMD_PREFIX'].'save to list commands'); } else { - if($GLOBALS['args'] == 'help') - { + switch($GLOBALS['args']) { + + case "help": CHANNEL_MSG('Save commands:'); CHANNEL_MSG('save auto_join - Saving auto join on channel when connected: !save auto_join '); CHANNEL_MSG('save auto_rejoin - Saving auto rejoin when kicked from channel: !save auto_rejoin '); @@ -26,93 +27,85 @@ function plugin_save() CHANNEL_MSG('save port - Saving port to config: !save port '); CHANNEL_MSG('save server - Saving server to config: !save server '); CHANNEL_MSG('save try_connect - Saving how many times try connect to server: !save try_connect '); - } - - if($GLOBALS['piece1'] == 'auto_join') - { + break; + + } + + switch($GLOBALS['piece1']) { + + case "auto_join": SaveData('../CONFIG.INI', 'CHANNEL', 'auto_join', $GLOBALS['piece2']); CHANNEL_MSG('Auto_join Saved.'); CLI_MSG('!save auto_join on: '.$GLOBALS['C_CNANNEL'].', New auto_join: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'auto_rejoin') - { + case "auto_rejoin": SaveData('../CONFIG.INI', 'AUTOMATIC', 'auto_rejoin', $GLOBALS['piece2']); CHANNEL_MSG('Auto_rejoin Saved.'); CLI_MSG('!save auto_rejoin on: '.$GLOBALS['C_CNANNEL'].', New auto_rejoin: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'channel') - { + case "channel": SaveData('../CONFIG.INI', 'CHANNEL', 'channel', $GLOBALS['piece2']); CHANNEL_MSG('Channel Saved.'); CLI_MSG('!save channel on: '.$GLOBALS['C_CNANNEL'].', New channel: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'command_prefix') - { + case "command_prefix": SaveData('../CONFIG.INI', 'COMMAND', 'command_prefix', $GLOBALS['piece2']); CHANNEL_MSG('Command_prefix Saved.'); CLI_MSG('!save command_prefix on: '.$GLOBALS['C_CNANNEL'].', New command_prefix: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'connect_delay') - { + case "connect_delay": SaveData('../CONFIG.INI', 'SERVER', 'connect_delay', $GLOBALS['piece2']); CHANNEL_MSG('Connect_delay Saved.'); CLI_MSG('!save connect_delay on: '.$GLOBALS['C_CNANNEL'].', New connect_delay: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'fetch_server') - { + case "fetch_server": SaveData('../CONFIG.INI', 'FETCH', 'fetch_server', $GLOBALS['piece2']); CHANNEL_MSG('Server Saved.'); CLI_MSG('!save fetch_server on: '.$GLOBALS['C_CNANNEL'].', New server: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'ident') - { + case "ident": SaveData('../CONFIG.INI', 'BOT', 'ident', $GLOBALS['piece2']); CHANNEL_MSG('Ident Saved.'); CLI_MSG('!save ident on: '.$GLOBALS['C_CNANNEL'].', New ident: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'name') - { + case "name": SaveData('../CONFIG.INI', 'BOT', 'name', $GLOBALS['piece2']); CHANNEL_MSG('Name Saved.'); CLI_MSG('!save name on: '.$GLOBALS['C_CNANNEL'].', New name: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'nick') - { + case "nick": SaveData('../CONFIG.INI', 'BOT', 'nickname', $GLOBALS['piece2']); CHANNEL_MSG('Nick Saved.'); CLI_MSG('!save nick on: '.$GLOBALS['C_CNANNEL'].', New nick: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'port') - { + case "port": SaveData('../CONFIG.INI', 'SERVER', 'port', $GLOBALS['piece2']); CHANNEL_MSG('Port Saved.'); CLI_MSG('!save port on: '.$GLOBALS['C_CNANNEL'].', New port: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'server') - { + case "server": SaveData('../CONFIG.INI', 'SERVER', 'server', $GLOBALS['piece2']); CHANNEL_MSG('Server Saved.'); CLI_MSG('!save server on: '.$GLOBALS['C_CNANNEL'].', New server: '.$GLOBALS['piece2']); - } + break; - if($GLOBALS['piece1'] == 'try_connect') - { + case "try_connect": SaveData('../CONFIG.INI', 'SERVER', 'try_connect', $GLOBALS['piece2']); CHANNEL_MSG('Try_connect Saved.'); CLI_MSG('!save try_connect on: '.$GLOBALS['C_CNANNEL'].', New try_connect: '.$GLOBALS['piece2']); - } + break; } + } } - ?> \ No newline at end of file diff --git a/PLUGINS/topic.php b/PLUGINS/topic.php index 4ef6a85..0caefb0 100644 --- a/PLUGINS/topic.php +++ b/PLUGINS/topic.php @@ -6,15 +6,12 @@ function plugin_topic() { - if(empty($GLOBALS['args'])) { CHANNEL_MSG('Usage: '.$GLOBALS['C_CMD_PREFIX'].'topic '); } - else { - $data = trim($GLOBALS['args']); - fputs($GLOBALS['socket'], 'TOPIC '.$GLOBALS['C_CNANNEL'].' '.$data."\n"); - - CLI_MSG('!topic on: '.$GLOBALS['C_CNANNEL'].', New topic: '.$data); - } + else { + fputs($GLOBALS['socket'], 'TOPIC '.$GLOBALS['C_CNANNEL'].' '.msg_without_command()."\n"); + CLI_MSG('!topic on: '.$GLOBALS['C_CNANNEL'].', New topic: \''.msg_without_command().'\''); + } } ?> \ No newline at end of file diff --git a/PLUGINS/uptime.php b/PLUGINS/uptime.php index f331202..497e9e9 100644 --- a/PLUGINS/uptime.php +++ b/PLUGINS/uptime.php @@ -8,7 +8,7 @@ function plugin_uptime() { $now = time(); - $time = $now - $GLOBALS['StartTime']; + $time = $now - START_TIME; $year=floor($time/(365*24*60*60)); $time-=$year*(365*24*60*60); diff --git a/PLUGINS/winamp.php b/PLUGINS/winamp.php new file mode 100644 index 0000000..a63d7a2 --- /dev/null +++ b/PLUGINS/winamp.php @@ -0,0 +1,51 @@ +'; + $plugin_command = 'winamp'; + +/* + NEED TO CONFIGURE! + Specify winamp CLAmp.exe program location + +*/ + $GLOBALS['winamp_loc'] = 'C:\Dokumenty\programy\Winamp\CLAmp.exe'; +//--- + + +function plugin_winamp() +{ + + if(empty($GLOBALS['args'])) { CHANNEL_MSG('Usage: '.$GLOBALS['C_CMD_PREFIX'].'winamp to list commands'); } + + else { + + switch($GLOBALS['args']) { + + case "help": + CHANNEL_MSG('Winamp commands:'); + CHANNEL_MSG('winamp stop - Stop music: !winamp stop'); + CHANNEL_MSG('winamp pause - Pause music: !winamp pause'); + CHANNEL_MSG('winamp play - Play music: !winamp play'); + CHANNEL_MSG('winamp next - Next song: !winamp next'); + CHANNEL_MSG('winamp prev - Previous song: !winamp prev'); + CHANNEL_MSG('winamp title - Show song title: !winamp title'); + break; + + case "stop": exec($GLOBALS['winamp_loc'].' /stop'); break; + case "pause": exec($GLOBALS['winamp_loc'].' /pause'); break; + case "play": exec($GLOBALS['winamp_loc'].' /play'); sendTitle($target); break; + case "next": exec($GLOBALS['winamp_loc'].' /next'); sendTitle($target); break; + case "prev": exec($GLOBALS['winamp_loc'].' /prev'); sendTitle($target); break; + case "title": sendTitle($target); break; + } + } +} + +function sendTitle($target) +{ + $title = exec($GLOBALS['winamp_loc'].' /title'); + CHANNEL_MSG("Playing: ".$title, $target); +} + +?> \ No newline at end of file diff --git a/readme.md b/readme.md index a04e6c6..dca84d5 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ ![Powered by S3x0r](http://minionki.com.pl/powered.png) -### Easy to use IRC BOT in PHP language, ready to use from first time +### Easy to use IRC BOT in PHP language, ready to use from first start
@@ -79,5 +79,6 @@ update -- Updates the BOT if new version is available: !update
 uptime -- Shows BOT uptime: !uptime
 voice -- Gives voice: !voice nick
 weather -- Shows actual weather: !weather city
+winamp -- Controls winamp: !winamp 
 
\ No newline at end of file diff --git a/readme.txt b/readme.txt index 2e5b889..c8c62da 100644 --- a/readme.txt +++ b/readme.txt @@ -67,4 +67,5 @@ topic -- Changing Topic in channel: !topic update -- Updates the BOT if new version is available: !update uptime -- Shows BOT uptime: !uptime voice -- Gives voice: !voice -weather -- Shows actual weather: !weather \ No newline at end of file +weather -- Shows actual weather: !weather +winamp -- Controls winamp: !winamp \ No newline at end of file