Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
config.php
logs/vikingbot.log
logs/*
db/*
18 changes: 18 additions & 0 deletions README → README-VikingBot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<a href="http://cryptoglance.info/" rel="external">http://cryptoglance.info</a>

----

### What is this?

We have forked <a href="https://github.com/Ueland/VikingBot" rel="external">Ueland/VikingBot</a> for our own personal use on our IRC Channel <a href="http://webchat.freenode.net/?channels=cryptoglance" rel="external">#cryptoGlance on freenode.net</a>.

### What does it do?

As this is a freshly forked repo, this is 100% identical to <a href="https://github.com/Ueland/VikingBot" rel="external">Ueland/VikingBot</a>. Features can be found <a href="https://github.com/cryptoGlance/cryptoGlance-irc-bot/blob/master/README-VikingBot">here</a>.

### We owe thanks to the following:

- [Ueland/VikingBot](https://github.com/Ueland/VikingBot)
- [LiteSaber](https://coinhuntr.com/) (For referring us to VikingBot)
7 changes: 4 additions & 3 deletions VikingBot.php → bot.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require("config.php");
require("plugins.php");
require("lib/functions.php");
require("lib/pluginInterface.php");

Expand All @@ -15,7 +16,7 @@

set_error_handler("errorHandler");

class VikingBot {
class Bot {

var $socket;
var $inChannel = false;
Expand Down Expand Up @@ -194,7 +195,7 @@ function restart($pass, $from, $chan) {

function prepareShutdown($msg) {
if(strlen($msg) == 0) {
$msg = "VikingBot - https://github.com/Ueland/VikingBot";
$msg = "cryptoGlance - http://cryptoglance.info";
}
sendData($this->socket, "QUIT :{$msg}");
foreach($this->plugins as $plugin) {
Expand Down Expand Up @@ -253,4 +254,4 @@ function antiFlood($user) {
}

//Start the bot
$bot = new VikingBot($config);
$bot = new Bot($config);
32 changes: 0 additions & 32 deletions config.dist.php

This file was deleted.

17 changes: 17 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

// Global Config
$config = array(
'server' => '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
);
37 changes: 36 additions & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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}";
}

/**
Expand Down
20 changes: 20 additions & 0 deletions plugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

//RSS Reader
$config['plugins']['rssReader'] = array(
array('title'=> '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')
// ),
//);
47 changes: 47 additions & 0 deletions plugins/autoOpPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

class autoOpPlugin implements pluginInterface {

var $config;
var $socket;

function init($config, $socket) {
$this->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;
}

}
2 changes: 1 addition & 1 deletion plugins/botLogPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]}");
Expand Down
2 changes: 1 addition & 1 deletion plugins/skeleton.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
This is an example skeleton for a Vikingbot plugin
This is an example skeleton for a plugin
**/
class examplePlugin implements pluginInterface {

Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
php VikingBot.php > logs/vikingbot.log 2>&1 &
php bot.php > logs/bot.log 2>&1 &
3 changes: 3 additions & 0 deletions thirdparty-plugins/links.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Links to other plugins for VikingBot:

Doorway/plugin for Roundup Issue Tracker https://gist.github.com/3295338