diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..412eeda --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index d684e76..cca6049 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.php -logs/vikingbot.log +logs/* +db/* \ No newline at end of file diff --git a/README b/README-VikingBot similarity index 72% rename from README rename to README-VikingBot index f9ce6c6..f322782 100644 --- a/README +++ b/README-VikingBot @@ -50,8 +50,26 @@ rssPlugin: upgradePlugin: - Plugin that upgrades the bot via git pull. + +autoOpPlugin: + - Plugin that gives +o to everyone or to certain nicks on channel join. +========== TEXT FORMATTING ========== +If you wish, you can format text the bot sends to a channel/user, via your plugins. +Use any of the following codes to apply the relevant text color or format. The text will +keep the given format until either end of string, or the {reset} tag. +Available colors: +{white}, {black}, {blue}, {green}, {red}, {darkRed}, {purple}, +{orange}, {yellow}, {lime}, {teal}, {cyan}, {lightBlue}, {pink}, {grey} & {lightGrey} + +Other tags: +{reset}, {bold} & {underline} + +Example: +"{bold}i am bold and {red}red{reset}, but now i am normal" + +PS: Different IRC-clients may display colors differently, some servers even deny color use! ========== BUGS/PROBLEMS? ========== Feel free to contact me via IRC on EfNet/Freenode/Undernet (Ueland) diff --git a/README.md b/README.md new file mode 100644 index 0000000..361b6aa --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +http://cryptoglance.info + +---- + +### What is this? + +We have forked Ueland/VikingBot for our own personal use on our IRC Channel #cryptoGlance on freenode.net. + +### What does it do? + +As this is a freshly forked repo, this is 100% identical to Ueland/VikingBot. Features can be found here. + +### We owe thanks to the following: + +- [Ueland/VikingBot](https://github.com/Ueland/VikingBot) +- [LiteSaber](https://coinhuntr.com/) (For referring us to VikingBot) \ No newline at end of file diff --git a/VikingBot.php b/bot.php similarity index 98% rename from VikingBot.php rename to bot.php index 18d6d39..12eb4bb 100644 --- a/VikingBot.php +++ b/bot.php @@ -1,6 +1,7 @@ socket, "QUIT :{$msg}"); foreach($this->plugins as $plugin) { @@ -253,4 +254,4 @@ function antiFlood($user) { } //Start the bot -$bot = new VikingBot($config); +$bot = new Bot($config); diff --git a/config.dist.php b/config.dist.php deleted file mode 100644 index b2e2ba2..0000000 --- a/config.dist.php +++ /dev/null @@ -1,32 +0,0 @@ - 'servername', //Server name, prefix it with "ssl://" in order to use SSL server - 'port' => 6666, //Server port - 'channel' => '#vikingbot', //Channel to join, use array('channel1', 'channel2') for multiple channels - 'name' => 'vikingbot', //Name of the bot - 'nick' => 'vikingbot', //Nick of the bot - 'pass' => '', //Server password - 'waitTime' => 10, //How many seconds to wait before joining channel after connecting to server - 'adminPass' => 'vikingbot', //Bot admin password, used for commands like !exit (!exit vikingbot) - 'memoryLimit' => '128', //Max memory the bot can use, in MB - 'memoryRestart' => '10', //Min memory usage, in MB. (The bot will try to clear RAM or restart if reached) - 'trigger' => '!', //What character should be used as bot command prefixes - 'maxPerTenMin' => 50 //Max messgages a user can send per 10 minutes before beeing ignored for that time -); - -//===================================== -//Plugin specific configuration -//===================================== - -//RSS Reader -$config['plugins']['rssReader'] = array( - array('title'=> 'VG', 'url'=>'http://www.vg.no/rss/nyfront.php?frontId=1', 'pollInterval'=>15, 'channel'=>'#vikingbot'), - array('title'=> 'BBC News', 'url'=>'http://feeds.bbci.co.uk/news/rss.xml', 'pollInterval'=>15, 'channel'=>'#vikingbot'), - array('title'=> 'CNN', 'url'=>'http://rss.cnn.com/rss/edition.rss', 'pollInterval'=>15, 'channel'=>'#vikingbot'), -); - -//File reader -$config['plugins']['fileReader'] = array( - 'channel' => '#vikingbot', -); diff --git a/config.php b/config.php new file mode 100644 index 0000000..871a564 --- /dev/null +++ b/config.php @@ -0,0 +1,17 @@ + 'chat.freenode.net', //Server name, prefix it with "ssl://" in order to use SSL server + 'port' => 6667, //Server port + 'channel' => array('#cryptoGlance'), //Channel to join, use array('channel1', 'channel2') for multiple channels + 'name' => 'cryptoGlance', //Name of the bot + 'nick' => 'cryptoGlance', //Nick of the bot + 'pass' => '', //Server password + 'waitTime' => 10, //How many seconds to wait before joining channel after connecting to server + 'adminPass' => '', //Bot admin password, used for commands like !exit (!exit vikingbot) + 'memoryLimit' => '128', //Max memory the bot can use, in MB + 'memoryRestart' => '10', //Min memory usage, in MB. (The bot will try to clear RAM or restart if reached) + 'trigger' => '!', //What character should be used as bot command prefixes + 'maxPerTenMin' => 50 //Max messgages a user can send per 10 minutes before beeing ignored for that time +); \ No newline at end of file diff --git a/lib/functions.php b/lib/functions.php index 6e9796f..c276717 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -32,10 +32,45 @@ function getNick($in) { */ function sendMessage($socket, $channel, $msg) { if(strlen($msg) > 2) { //Avoid sending empty lines to server, since all data should contain a line break, 2 chars is minimum + $msg = prettify($msg); sendData($socket, "PRIVMSG {$channel} :{$msg}"); } } +/** + * Converts color / formatting codes to IRC-syntax + * + */ +function prettify($msg) { + // Reset Colours/Styling + $msg = str_replace("{reset}", "\017", $msg); + + // Colours + $msg = str_replace("{white}", "\0030", $msg); + $msg = str_replace("{black}", "\0031", $msg); + $msg = str_replace("{blue}", "\0032", $msg); + $msg = str_replace("{green}", "\0033", $msg); + $msg = str_replace("{red}", "\0034", $msg); + $msg = str_replace("{darkRed}", "\0035", $msg); + $msg = str_replace("{purple}", "\0036", $msg); + $msg = str_replace("{orange}", "\0037", $msg); + $msg = str_replace("{yellow}", "\0038", $msg); + $msg = str_replace("{lime}", "\0039", $msg); + $msg = str_replace("{teal}", "\00310", $msg); + $msg = str_replace("{cyan}", "\00311", $msg); + $msg = str_replace("{lightBlue}", "\00312", $msg); + $msg = str_replace("{pink}", "\00313", $msg); + $msg = str_replace("{grey}", "\00314", $msg); + $msg = str_replace("{lightGrey}", "\00315", $msg); + + // Styling + $msg = str_replace("{bold}", "\002", $msg); + $msg = str_replace("{underline}", "\017", $msg); + $msg = str_replace("{bold}", "\002", $msg); + + return $msg; +} + /** * Sends data to server */ @@ -88,7 +123,7 @@ function logMsg($msg) { if(!stringEndsWith($msg, "\n")) { $msg .= "\n"; } - echo "[".date("t.M.y H:i:s")."] {$msg}"; + echo "[".date("d.M.y H:i:s")."] {$msg}"; } /** diff --git a/plugins.php b/plugins.php new file mode 100644 index 0000000..7a332cd --- /dev/null +++ b/plugins.php @@ -0,0 +1,20 @@ + 'cryptoGlance', 'url'=>'http://www.reddit.com/r/cryptoglance/.rss', 'pollInterval' => 15, 'channel'=> $config['channel'][0]), +); + +//File reader -- not used +//$plugins['fileReader'] = array( +// 'channel' => '#cryptoglance', +//); + +//Auto Op -- not used +//$plugins['autoOp'] = array( +// 'mode' => '0', // autop mode, 0 = disabled, 1 = only configured users, 2 = autoop everyone +// 'channel' => array( +// '#channel1' => array('nick1','nick2','nick3','nick4','nick5','nick6','nick7','nick8'), +// '#channel2' => array('ueland','ernini') +// ), +//); diff --git a/plugins/autoOpPlugin.php b/plugins/autoOpPlugin.php new file mode 100644 index 0000000..be20d1f --- /dev/null +++ b/plugins/autoOpPlugin.php @@ -0,0 +1,47 @@ +config = $config; + $this->socket = $socket; + $this->autoOpConfig = $config['plugins']['autoOp']; + } + + function tick() { + + } + + function onMessage($from, $channel, $msg) { + + } + + function onData($data) { + + if ($this->autoOpConfig['mode']) { + + if (strpos($data,'JOIN :') !== false) { + $bits = explode(" ", $data); + $nick = getNick(@$bits[0]); + $channel = trim(str_replace(":", '', @$bits[2])); + + if ($this->autoOpConfig['mode'] == 1) { + if (in_array($nick, $this->autoOpConfig['channel'][$channel])) { + sendData($this->socket, "MODE {$channel} +o {$nick}"); + } + } elseif ($this->autoOpConfig['mode'] == 2) { + sendData($this->socket, "MODE {$channel} +o {$nick}"); + } + + } + } + } + + function destroy() { + $this->socket = null; + } + +} diff --git a/plugins/botLogPlugin.php b/plugins/botLogPlugin.php index f1bbc17..e7fc69b 100644 --- a/plugins/botLogPlugin.php +++ b/plugins/botLogPlugin.php @@ -45,7 +45,7 @@ function onMessage($from, $channel, $msg) { //Password auth ok, display log data sendMessage($this->socket, $channel, "{$from}: Last {$limit} entries from bot log:"); - $logdata = file('logs/vikingbot.log'); + $logdata = file('logs/bot.log'); $rows = count($logdata); for($i=$rows - $limit; $i<$rows; $i++){ sendMessage($this->socket, $channel, "{$logdata[$i]}"); diff --git a/plugins/skeleton.txt b/plugins/skeleton.txt index 059884a..b71edae 100644 --- a/plugins/skeleton.txt +++ b/plugins/skeleton.txt @@ -1,7 +1,7 @@ logs/vikingbot.log 2>&1 & +php bot.php > logs/bot.log 2>&1 & diff --git a/thirdparty-plugins/links.php b/thirdparty-plugins/links.php new file mode 100644 index 0000000..762c8b3 --- /dev/null +++ b/thirdparty-plugins/links.php @@ -0,0 +1,3 @@ +Links to other plugins for VikingBot: + +Doorway/plugin for Roundup Issue Tracker https://gist.github.com/3295338