Skip to content

Added nick2, nick3 in serve_mod #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
20 changes: 14 additions & 6 deletions modules/serve/serve_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public function init() {
$this->serve["triggers"]["icecream"][] = "here [nick]... one ball for you only ([today]/[total]/[sumtotal])";
$this->serve["triggers"]["icecream"][] = "finds a biig icecream for [nick] eat and you get for free (50$ to use toilet) ([today]/[total]/[sumtotal])";
$this->serve["triggers"]["icecream"][] = "dusts off something that look like icecream from the corner of fridge, here [nick] ([today]/[total]/[sumtotal])";

//FUN
$this->serve["triggers"]["fun"][] = "stjæler [nick2]'s muldvarp og propper den i lommen på [nick3]. Jeg har nakket en pung [today]. gang idag. Og jeg har prøvet så mange [total] gange. Alt i alt fik jeg den [sumtotal] gange";
$this->serve["triggers"]["fun"][] = "piller [nick2]'s hjul af bilen og forære dem til [nick3] ([today]/[total]/[sumtotal])";
//END

// - docu:
// [nick] = nick that triggered, [today] how many heads/coffee person had today
// [total] = how many nick had it total, [last] time of last, [since] time since last
Expand Down Expand Up @@ -111,6 +117,8 @@ public function timer_serve($args = false) {
public function priv_serve($line, $args) {
$chan = strtolower($line['to']);
$nick = $line['fromNick'];
$nick2 = $args["arg1"];
$nick3 = $args["arg2"];
$address = $line["fromIdent"]."@".$line["fromHost"];
$network = $this->ircClass->getServerConf ("NETWORK");

Expand Down Expand Up @@ -159,19 +167,19 @@ public function priv_serve($line, $args) {
else {
// else add
//$this->ircClass->privMsg("$chan", "not found in db ($nick - $address) .. adding");
$ires = $this->db->query("INSERT INTO `layer13`.`servestats` (`id`, `nick`, `address`, `type`, `last`, `today`, `total`, `channel`, `network`)
VALUES (NULL, ".sqlesc($nick).", ".sqlesc($address).", ".sqlesc($trigger).", UNIX_TIMESTAMP(), '1', '1', ".sqlesc($chan).", ".sqlesc($network).");");
$ires = mysql_query("INSERT INTO `predb`.`servestats` (`id`, `nick`, `nick2`, `nick3`, `address`, `type`, `last`, `today`, `total`, `channel`, `network`)
VALUES (NULL, ".sqlesc($nick).", ".sqlesc($nick2).", ".sqlesc($nick3).", ".sqlesc($address).", ".sqlesc($trigger).", UNIX_TIMESTAMP(), '1', '1', ".sqlesc($chan).", ".sqlesc($network).");");
}
}

// grab info from db parse reply and return result
$ures = $this->db->query("SELECT * FROM servestats WHERE nick LIKE ".sqlesc($nick)." AND network LIKE '$network' AND type LIKE ".sqlesc($trigger)." LIMIT 1");
// grab info from db parse reply and return result
$ures = mysql_query("SELECT * FROM servestats WHERE nick LIKE ".sqlesc($nick)." AND network LIKE '$network' AND type LIKE ".sqlesc($trigger)." LIMIT 1");
$urow = mysql_fetch_assoc($ures);
//grap totals
$tres = $this->db->query("SELECT sum(total) as sumtotal, sum(today) as sumtoday FROM servestats WHERE network LIKE '$network' AND type LIKE ".sqlesc($trigger)." LIMIT 1");
$tres = mysql_query("SELECT sum(total) as sumtotal, sum(today) as sumtoday FROM servestats WHERE network LIKE '$network' AND type LIKE ".sqlesc($trigger)." LIMIT 1");
$trow = mysql_fetch_assoc($tres);

$message = str_replace(array("[nick]", "[today]", "[total]", "[sumtotal]", "[sumtoday]"), array("$nick", $urow["today"], $urow["total"], $trow["sumtotal"],$trow["sumtoday"]), $reply);
$message = str_replace(array("[nick]", "[nick2]", "[nick3]", "[today]", "[total]", "[sumtotal]", "[sumtoday]"), array("$nick", "$nick2", "$nick3", $urow["today"], $urow["total"], $trow["sumtotal"],$trow["sumtoday"]), $reply);
//lookup nick or insert, update stats and reply
//$this->ircClass->privMsg("$chan", "trigger: $trigger - $reply @ $chan/$network");
$this->ircClass->privMsg("$chan", "$message");
Expand Down
2 changes: 2 additions & 0 deletions modules/serve/shcema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
CREATE TABLE IF NOT EXISTS `servestats` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nick` varchar(32) CHARACTER SET latin1 NOT NULL,
`nick2` varchar(32) CHARACTER SET latin1 NOT NULL,
`nick3` varchar(32) CHARACTER SET latin1 NOT NULL,
`address` varchar(255) CHARACTER SET latin1 NOT NULL,
`type` varchar(255) CHARACTER SET latin1 NOT NULL,
`last` decimal(11,0) NOT NULL,
Expand Down