collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Timer fuction to work with latest svn release  (Read 3683 times)

0 Members and 1 Guest are viewing this topic.

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Timer fuction to work with latest svn release
« on: February 07, 2007, 06:39:46 pm »
would it be posible to get an offical timer function to work with the latest svn release.. I dont mind editing things and changing things around but would like to have something that is already set up for .3 svn.. if at all posble.. or at least the Org side of bebot..  I havent tried the custom timers yet for the .2 but I am thinking about looking at them see if it would work with the svn release..

Nytridr
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Timer fuction to work with latest svn release
« Reply #1 on: February 07, 2007, 09:55:26 pm »
The ones for 0.2 should work just fine and is likely going to be added to 0.3
BeBot Founder and Fixer Kingpin

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: Timer fuction to work with latest svn release
« Reply #2 on: February 08, 2007, 12:48:17 am »
okay took my stab at upgrading this mod.. not sure how well I did but at first glance it seems to be working..

Code: [Select]
<?
/*
* Customtimers.php - Timers plugin
*
* Coded by Wanuarmi, Sabkor, Jackjonez (RK1)
* Requires Module Settings plugin by Glarawyn (v2.0.3 or above)
*
*/

$customTimers = new CustomTimers($bot);

$db -> query("CREATE TABLE IF NOT EXISTS `#___timers` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`setby` VARCHAR( 100 ) NOT NULL ,
`description` VARCHAR( 255 ) NOT NULL ,
`expires` INT( 11 ) NOT NULL ,
`tell` BOOLEAN ,
PRIMARY KEY ( `id` )
);"); 

$commands["tell"]["timer"] = &$customTimers;
$commands["pgmsg"]["timer"] = &$customTimers;
$commands["gc"]["timer"] = &$customTimers;
$commands["tell"]["timers"] = &$customTimers;
$commands["pgmsg"]["timers"] = &$customTimers;
$commands["gc"]["timers"] = &$customTimers;

$cron["2sec"][] = &$customTimers;


class CustomTimers
{
var $bot;
var $timers;
var $output;
var $output2;
var $date_format;
var $description_color;
var $time_color;
var $id_color;

function CustomTimers (&$bot)
{
$this -> bot = &$bot;
       
//add default settings if they don't already exist
if (!isset($this -> bot -> settings['Customtimers']['0mins']))
{
$module = "Customtimers";
$longdesc = "Alert via tell at timer finish.";
$this -> bot -> set -> create ($module, "0mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=6);
$longdesc = "Alert via tell at 5 minutes.";
$this -> bot -> set -> create ($module, "5mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=5);
$longdesc = "Alert via tell at 15 minutes.";
$this -> bot -> set -> create ($module, "15mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=4);
$longdesc = "Alert via tell at 30 minutes.";
$this -> bot -> set -> create ($module, "30mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=3);
$longdesc = "Alert via tell at 1 hour.";
$this -> bot -> set -> create ($module, "60mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=2);
$longdesc = "Alert via tell at 2 hours.";
$this -> bot -> set -> create ($module, "120mins", TRUE, $longdesc, "On;Off", FALSE, $disporder=1);
$longdesc = "Sending of notifications to GC.";
$this -> bot -> set -> create ($module, "gcoutput", TRUE, $longdesc, "On;Off", FALSE, $disporder=7);
$longdesc = "Sending of notifications to Pgroup.";
$this -> bot -> set -> create ($module, "pgoutput", TRUE, $longdesc, "On;Off", FALSE, $disporder=8);
unset($longdesc);
unset($module);
}

$this -> date_format = "H:i:s d/m/y";
$this -> description_color = "#31D6FF";//#FF3131
$this -> time_color = "#C6D6FF";
$this -> id_color = "#FFCC66";//white
$this -> load_timers();
}


function tell($name, $msg)
{
$this -> bot -> send_tell($name, $this -> process_command($name, $msg, 0));
}


function pgmsg($name, $msg)
{
$this -> bot -> send_pgroup($this -> process_command($name, $msg, 0));
}


function gc($name, $msg)
{
$this -> bot -> send_gc($this -> process_command($name, $msg, 0));
}


function process_command($name, $msg, $tell)
{
if (preg_match("/^" . $this -> bot -> commpre . "timer$/i", $msg))
return $this -> show_timers();
if (preg_match("/^" . $this -> bot -> commpre . "timers$/i", $msg))
return $this -> show_timers();
if (preg_match("/^" . $this -> bot -> commpre . "timer ([0-9]+)$/i", $msg, $info))
return $this -> show_timer($info[1]);
if (preg_match("/^" . $this -> bot -> commpre . "timer ([0-9][0-9]?):([0-9][0-9]?):([0-9][0-9]?):([0-9][0-9]?) (.*)$/i", $msg, $info))
return $this -> set_timer($name, $info[1], $info[2], $info[3], $info[4],  $info[5], $tell);
if (preg_match("/^" . $this -> bot -> commpre . "timer ([0-9][0-9]?):([0-9][0-9]?):([0-9][0-9]?) (.*)$/i", $msg, $info))
return $this -> set_timer($name, $info[1], $info[2], $info[3], $info[4], $tell);
if (preg_match("/^" . $this -> bot -> commpre . "timer ([0-9][0-9]?):([0-9][0-9]?) (.*)$/i", $msg, $info))
return $this -> set_timer($name, $info[1], $info[2], 0, $info[3], $tell);
if (preg_match("/^" . $this -> bot -> commpre . "timer ([0-9][0-9]?) (.*)$/i", $msg, $info))
return $this -> set_timer($name, 0, $info[1], 0, $info[2], $tell);
if (preg_match("/^" . $this -> bot -> commpre . "timer del ([0-9]+)$/i", $msg, $info))
return $this -> delete_timer($info[1]);
return "Invalid syntax.  Please /tell <botname> <pre>help <pre>timer";
}


function set_timer($name, $days, $hours, $minutes, $seconds, $description, $tell)
{
$stamp = TIME() + ($days*60*60*24) + ($hours*60*60) + ($minutes*60) + $seconds;
$this -> bot -> db -> query("INSERT INTO #___timers" . " (setby, description, expires, tell) VALUES ('$name', '$description', $stamp, $tell)");
$this -> load_timers();
return "Timer set.";
}


function load_timers()
{
$this -> timers = $this -> bot -> db -> select("SELECT * FROM #___timers" . " WHERE expires > ".TIME()." ORDER BY expires ASC");
$this -> update_output();
}


function delete_timer($id)
{
        $result = $this -> bot -> db -> select ("SELECT id FROM #___timers" . " WHERE id = $id");
        if (empty($result)) return "No timer with that ID.";
$this -> bot -> db -> query("DELETE FROM #___timers" . " WHERE id = $id");
$this -> load_timers();
return "Timer deleted.";
}


// keeps a list updated so we dont have to make one all the time
function update_output()
{
$description_color = $this -> description_color;
$time_color = $this -> time_color;
$id_color = $this -> id_color;
$output = "";
if (!empty($this -> timers)) {
foreach($this -> timers AS $timer)
{
$time = gmdate($this -> date_format, $timer[3]);
$remaining = $this -> format_seconds($timer[3] - TIME());
$output .= "\n\n<font color=$id_color>#$timer[0]: </font><font color=$time_color>$time </font><font color=$id_color>remains: $remaining</font> '<font color=$description_color>$timer[2]</font>' ";
$output .= "<font color=$time_color>Set by: " . $timer[1] . " </font><a href='chatcmd:///tell <botname> <pre>timer del " . $timer[0] . "'>[Delete]</a>";
}
}
$this -> output = $output;
}


function show_timers()
{
if (empty($this -> output))
{
return "No timers set.";
}
else
{
$this -> load_timers();
$output = "<font color=CCInfoHeader>::::: TIMERS :::::\n" . $this -> output;
$output .= "\n\n\nTime now " . gmdate($this -> date_format, TIME());
return "Timers :: " . $this -> bot -> make_blob("click to view", $output);
}
}


function show_timer($id)
{
if (empty($this -> output))
{
return "Timer $id does not exist.";
}
else
{
$dcolor = $this -> description_color;
$tcolor = $this -> time_color;
        $result = $this -> bot -> db -> select ("SELECT * FROM #___timers" . " WHERE id = $id");
        if (empty($result)) return "Timer $id does not exist.";
$remain = $this -> format_seconds($result[0][3] - TIME());
$desc = $result[0][2];
return "Timer: <font color=$dcolor>$desc <font color=$tcolor>in $remain";
}
}


function format_seconds($totalsec)
{
$days = ( $totalsec / (60*60*24) );
$resthrs = $totalsec % (60*60*24);
$hours = floor( $resthrs / (60*60) );
$rest = $totalsec % (60*60);
$minutes = floor( $rest / 60 );
$seconds = $rest % 60;
return sprintf("Days:<font color=#ff0000>%02d</font> Hours:<font color=#ff0000>%02d</font> Minutes:<font color=#ff0000>%02d</font> Seconds:<font color=#ff0000>%02d</font>", $days, $hours, $minutes, $seconds);
}


function cron()
{
if (empty($this -> timers)) return;

$dcolor = $this -> description_color;
$tcolor = $this -> time_color;

foreach($this -> timers AS $timer)
{
$secleft = $timer[3] - TIME();


// Need a Cron job here to send it out hourly if it is above an hour.  the rest will be for 45 mins 30 min 15 mins and 5 mins.




if( $secleft <= 3600 && $secleft >= 3599 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>in 1 hour</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['60mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}
}

else if( $secleft <= 7200 && $secleft >= 7199 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>in 2 hours</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['120mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}
}

else if( $secleft <= 1800 && $secleft >= 1799 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>in 30 minutes</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['30mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}
}

else if( $secleft <= 900 && $secleft >= 899 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>in 15 minutes</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['15mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}

}

else if( $secleft <= 300 && $secleft >= 299 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>in 5 minutes</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['5mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}
}

else if( $secleft <= 1 )
{
$msg = "TIMER: <font color=$dcolor>$timer[2] <font color=$tcolor>now</font>!";
if($timer[4] == 0)
{
if ($this -> bot -> settings['Customtimers']['0mins'])
{
$this -> bot -> send_tell($timer[1], $msg);
}

if ($this -> bot -> settings['Customtimers']['gcoutput'])
$this -> bot -> send_gc($msg);
if ($this -> bot -> settings['Customtimers']['pgoutput'])
$this -> bot -> send_pgroup($msg);
}
$this -> bot -> db -> query("DELETE FROM #___timers" . " WHERE id = ".$timer[0]);
$this -> load_timers();
}
}
}
}
?>

Thank you for this mod

Plugin Name: Custom Timers v2 (guildbot)
Keywords: !timer, !timers
Contributor: Wanuarmi, Sabkor, Jackjonez
Forum Topic: Here
Notes: Sets timer features on the bot.  Requires module settings plugin.


http://bebot.link/index.php/topic,208.msg4506.html#msg4506


Nytridr
« Last Edit: February 08, 2007, 03:04:35 am by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: Timer fuction to work with latest svn release
« Reply #3 on: February 08, 2007, 12:50:53 am »
What would I add to this to send it every hour untill deleted?  instead of only the last couple hours?

Nytridr

umm maybe this should be moved to .3 support or something.. I will let you all decide that one..
« Last Edit: February 08, 2007, 01:07:53 am by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: Timer fuction to work with latest svn release
« Reply #4 on: February 08, 2007, 03:02:20 am »
okay I need a cron job that will look at the time and on every hour it will send a message.. I have changed even more of this mod to add days to it, and have that working.. and I am getting the correct reply back in tells.. now I just need the cron job to send it out to the org..

would someone help me a bit here..

Nytridr

I have also updated the code above to reflect my changes..

I also need the following code motified to check for a permission to delete.. as of right now anyone can delete the timer.. I would like to have admin + to be able to delete any timer.. but right now I suppose make it where only the person that made the timer can delete it.. since I know the security mod is still in dev..

Code: [Select]
function delete_timer($id)
{
        $result = $this -> bot -> db -> select ("SELECT id FROM #___timers" . " WHERE id = $id");
        if (empty($result)) return "No timer with that ID.";
$this -> bot -> db -> query("DELETE FROM #___timers" . " WHERE id = $id");
$this -> load_timers();
return "Timer deleted.";
}


« Last Edit: February 08, 2007, 06:28:54 am by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Dream

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Timer fuction to work with latest svn release
« Reply #5 on: February 10, 2007, 01:13:36 pm »
Heya,
Just thought I'd post my modified personal timers module for you to use/look at.

Reminds every hour, then more frequent within the last hour.

Reminds to guild chat if set there, raid chat if set there or to the person who set it if set in a tell.

You can view all timers set, just your own timers, just guild or raid timers, or anybodys personal timers.

Only admin, superadmin or the creator can delete timers set.

It's also persistent, ie if the bot dies, or diconnects/reconnects the timers will flush/pick up where they left off.

I've been asked to provide personal timer profiles also, which would allow individual users to set the frequency of their reminders, but that will come after I have addressed the many other tasks I have ongoing at the moment with the compilation this came from.

Peace,
Dream.

http://82.22.128.129/CustomTimers.zip

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 220
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal