BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: craized on January 16, 2005, 01:31:09 am

Title: Custom modules
Post by: craized on January 16, 2005, 01:31:09 am
I didn't know where to put these, but I figured they would be appreciated.
If anyone knows what they're doing and wants to clean them up, please do so and let me know, so I can change them on my bot. So far this has been an awesome bot, thank you for your effort.
Leader Chat Echo Module (http://www.craized.net/junk/bebot/modules/LeadEcho.zip)
A module to echo whatever an appointed raid leader says in ugly noticeable colors.
Timer Module (http://www.craized.net/junk/bebot/modules/Timer.zip)
A countdown timer used for waiting out monster spawn times, or mob resets.
Title: Custom modules
Post by: craized on January 18, 2005, 09:32:52 am
Notify Module (http://www.craized.net/junk/bebot/modules/Notify.zip)
If you're running a raid bot, there is no notify when people come online, so if you want a players whois info to be displayed when they join the privategroup, this is for you.

EDIT: Thank you for the correction. I'm hoping to get a teams module up, but I'm terrible with Object Oriented Programming, so I'm stuck.
Title: Custom modules
Post by: Sputnik on January 25, 2005, 06:50:41 am
http://www.craized.net/junk/bebot/modules/Notify.php <---this link is wrong

It should be

http://www.craized.net/junk/bebot/modules/Notify.zip

Just letting ya know craized. Great modules btw.
Title: Custom modules
Post by: craized on January 25, 2005, 08:19:21 am
The link is edited, thank you Sputnik. I keep finding nasty bugs in my modules, especially the timer. The newest versions are bug free as far as I know. If you find bugs, post them here, or send me an e-mail at [email protected]

Thank you for your support.
Title: Custom modules
Post by: craized on January 26, 2005, 09:57:46 am
Changed the Timer Module (http://www.craized.net/junk/bebot/modules/Timer.zip) so now in order to set the timer you use !timer <time>, and it now echos
'<player> your timer has gone off.'
rather than just beeping. Also, only the player who set the timer can reset the timer. I'm hoping to allow the raid leader from my Lead Echo Module (http://www.craized.net/junk/bebot/modules/LeadEcho.zip) to clear timers as well, but I'm having trouble communicating between classes.
Title: Custom modules
Post by: Blondengy on January 26, 2005, 10:54:17 am
Communications between classes will be made a lot easier with the next major updated of the bot.

Quick example on the work-around way you have to do it atm:
You got two classes:
Class A
Class B

Class A is called on a tell with the command !a ($commands["tell"]["a"])
It has a function called "doSomething($var1, $var2)" which you wanna call from Class B

Now in Class B do:
$this -> bot -> commands["tell"]["a"] -> doSomething($somevar, $someothervar);
Title: Custom modules
Post by: craized on January 26, 2005, 11:14:45 am
Thanks for the lovely workaround, now admins and timer creators can reset the timer. I'm getting tired of writing out the link, so just use a different one to my Timer Module.
Title: Custom modules
Post by: craized on January 28, 2005, 11:57:32 am
Teams Module! (http://www.craized.net/junk/bebot/modules/Teams.zip)
I finished it! I'm very excited, because it was a terrible pain for me. I've got a lot of redundant code, and would love for someone to help me clean it up. But for now, it works. It acts almost exactly as raidbots such as mordnet etc. So enjoy!
Title: Custom modules
Post by: craized on February 02, 2005, 03:47:41 am
MOTD module here, spams org chat every <delay> for <duration>.

MOTD Module (http://www.craized.net/junk/bebot/modules/MOTD.zip)
Title: Custom modules
Post by: Lal on March 04, 2005, 06:30:04 pm
Teams module bug:
                     foreach($this -> team as $team1=>$spo1t) {


has to be

                     foreach($this -> team as $team1=>$spot1) {

or something... but still its no working, only can join team 1, not 2,3,4,5,6,7,8,9
Title: Custom modules
Post by: craized on March 07, 2005, 01:04:18 pm
I had it set up so that there are only enough teams for the people in the bot. If there are less than 7 people, 1 team is available. Less than 25, 4 teams are available etc.
Title: Cool
Post by: cybershead on March 07, 2005, 09:32:33 pm
I find it cool but could you do so Admin can do in tells to bot and mayb
 !showmeteams command would open a text window like when you do
 !callers so you can see what teams you have been assined too,,I did try to fiddle around with the code but i dont know enough about it yet :)
Title: Custom modules
Post by: Lal on March 07, 2005, 10:21:38 pm
Quote from: "craized"
I had it set up so that there are only enough teams for the people in the bot. If there are less than 7 people, 1 team is available. Less than 25, 4 teams are available etc.


Any way to NOT count the members in it, since some teams have to get balanced, ie: 2 and 4 or something

Like making it count howmany teams have members and then make sure there are always 3 free other teams
Title: Custom modules
Post by: craized on March 11, 2005, 12:23:36 pm
Teams Module (http://www.craized.net/junk/bebot/modules/Teams.zip)
New and improved. Added two new commands,
!teams num auto
!teams num <number>
'num auto' is the default setting, and it acts the way I originally planned the teams. num <number> allows an administrator or raid leader to specify the number of teams available. I hope this caters to everyones needs.
Title: Custom modules
Post by: Lal on March 11, 2005, 06:32:47 pm
cool, thanks =)
Title: Custom modules
Post by: craized on March 11, 2005, 06:49:19 pm
I screwed up a line and haven't had a chance to update the copy on my webserver, so heres the fixed version.


EDIT: Pulling out my posted code, module available at http://www.craized.net/junk/bebot/modules/Teams.zip
Title: Custom modules
Post by: craized on March 28, 2005, 03:27:19 am
I hate posting these big chunks of code over and over, but a big bug came to my attention recently. If someone leaves the bot channel, then you clear the teams, they are put into the unteamed catagory, and stay there forever. My bot ended up with 20 or so users permanently in the bot, causing a bit of confusion. This new code should fix it.

EDIT: Took out the new code because I uploaded it. Download it at
http://www.craized.net/junk/bebot/modules/Teams.zip
Title: Custom modules
Post by: craized on April 04, 2005, 11:53:33 am
New module!
I was tired of joining Tnet every time I wanted to check the alien playfield timer, so I made a BE Bot module for it. If your bot is set up as a guildbot as well, you can type <pre>pf in guild, a tell, or private group. I've only spent a day on this so far, so there may be a few minor timing issues. I believe its 7 hours 12 minutes between the gates opening. If anyone has a more exact figure for me, please PLEASE, e-mail me, or post here. I hope you enjoy!

Alien Playfield Module (http://www.craized.net/test/bebot/modules/Playfield.zip)

NOTE: Timer is wrong, I have to fix it I'll post again when the time is correct. I'm having trouble finding the exact interval, I think I'll have to camp the seven hours.  :shock:
Title: Custom modules
Post by: craized on April 05, 2005, 07:18:35 am
AFK module! (http://www.craized.net/junk/bebot/modules/AFK.zip)
I assume this is self explanatory, per request I finally made this.
Title: Custom modules
Post by: Foxferal on April 05, 2005, 09:55:35 am
Nice indeed! Just like I wanted it, with a slight difference. (on an !online I would like to see who is afk and who is not in the given blob). A bit different way then I was planning to do it, but this looks neat, prolly neater in the end than my idea. (I would have gone the sql-route of stored values)

And a little bug:

On line 54-55: (same on line 72-73)
Code: [Select]
if(preg_match("/$key\b/i", $msg)) {
$this -> bot -> send_pgroup($key . " is AFK (" . $value . ")");


The bot reacts to its own given $key value. Result: flood.

[Mocktest] Foxferal: !afk
[Mocktest] Mocktest: Foxferal is now AFK.
[Mocktest] Mocktest: Foxferal is AFK (Away from keyboard)
[Mocktest] Mocktest: Foxferal is AFK (Away from keyboard)
[Mocktest] Mocktest: Foxferal is AFK (Away from keyboard)

Any idea on this? "Early" morning here and its about 4-5 hours before my brain starts to function... you could remove the $key value and just give a 'The user is AFK', but thats a bit boring, dont you think? ;)
Title: Custom modules
Post by: craized on April 05, 2005, 10:22:41 am
I don't have the flooding problem. I may have made a change that was not used in the uploaded version, try looking here or differences.
http://www.craized.net/junk/bebot/highlight?AFK

The reason I don't want to use a database for this information is because if for some reason the bot experiences a disconnect, the afk messages will be stored, thus keeping members away who should not be. On the other hand, a db would be much much easier to access  :P

I'll look at it today, but I have to wake up in a few hours.
Title: Custom modules
Post by: craized on April 05, 2005, 10:43:36 am
Turn out to be a quick thing
Code: [Select]
if($name != "Dosraids") {
change this to
Code: [Select]
if($name != $this -> bot -> botname) {
and add it into the gc function as well. I used my bot's name on accident for testing purposes and forgot to change it. This will make sure that the afk message isn't echoed when the bot says a players name.

This link has the updated code, I'll upload the new zip file as soon as I get a chance.

http://www.craized.net/junk/bebot/highlight?AFK

Thank you for the bug report  :D
Title: Custom modules
Post by: Foxferal on April 06, 2005, 12:09:47 am
!afk works like a charm now, thanks :)

well... only one little detail.... ;)

To show in the list if listed users are afk, on an !online... that would pull the plugin into perfection... :D
Title: Custom modules
Post by: craized on April 06, 2005, 06:45:24 am
Hate making these huge posts, but here's the new Online.php in the core folder of your bot.

EDIT: Modded Online.php code added to my AFK modules zip package at
http://www.craized.net/junk/bebot/modules/AFK.zip

Change this, if theres any bugs, please let me know.
Title: Custom modules
Post by: Lal on April 06, 2005, 09:21:27 pm
WTB AI lvl also o.O
Title: Custom modules
Post by: Lal on April 06, 2005, 09:32:00 pm
Warning: Division by zero in C:\BeBot\modules\AFK.php on line 64

when using !afk, doesnt do anything




and its showing this:

 in !online:

Soldier
 - Lvl 200 Lalsoldier (Squad Commander) :: 768689656's Alts ::


commpre . "afk(.)*"/i, $msg
changed to
commpre . "afk(.)*/i", $msg


[Virtual Insanity] Lalsoldier: !afk
[Virtual Insanity] Vibot: Lalsoldieris now AFK.



ok, well still a missing space and showing id as alts.. :S
200 Lalsoldier (Squad Commander) :: 768689656's Alts ::(
Title: Custom modules
Post by: Lal on April 06, 2005, 09:37:07 pm
Quote from: "craized"
New module!
I was tired of joining Tnet every time I wanted to check the alien playfield timer, so I made a BE Bot module for it. If your bot is set up as a guildbot as well, you can type <pre>pf in guild, a tell, or private group. I've only spent a day on this so far, so there may be a few minor timing issues. I believe its 7 hours 12 minutes between the gates opening. If anyone has a more exact figure for me, please PLEASE, e-mail me, or post here. I hope you enjoy!

Alien Playfield Module (http://www.craized.net/test/bebot/modules/Playfield.zip)

NOTE: Timer is wrong, I have to fix it I'll post again when the time is correct. I'm having trouble finding the exact interval, I think I'll have to camp the seven hours.  :shock:


7hours 20mins If I remember right
Title: Custom modules
Post by: Lal on April 06, 2005, 10:33:31 pm
oh well, your afk then... how to un-afk?

!afk doesnt work..


                    if(preg_match("#$key\b#i", $msg)) {
                        $this -> bot -> send_pgroup($key . " is AFK (" . $value . ")");


IS different then


                    if(preg_match("/$key\b/i", $msg)) {
                        $this -> bot -> send_gc($key . " is AFK \(" . $value . "\)");  

huh???
Title: Custom modules
Post by: craized on April 07, 2005, 01:36:32 am
Thank you for the 7 hours 20 minutes, I'll check it out. To un-afk, simply say anything in chat. I haven't set up any alt records for myself, so I wasn't aware of that bug. I'll look into it. Also, this is only a raid bot for me, so I didn't get a chance to test the guild chat section, I'll make that fix as well.
Title: Custom modules
Post by: craized on April 07, 2005, 01:45:35 am
After testing and looking through my code, I've made a few minor changes, but I haven't had any trouble with my alts records. I changed the guild afk notice so that it no longer has \ in front of the () and moved the " in the expression match, but could not find any other problems. Thank you very much for your help, I'll upload my changes in about 5 minutes.
Title: Custom modules
Post by: craized on April 07, 2005, 01:57:45 am
I just completed my new Loot Module (http://www.craized.net/junk/bebot/modules/Loot.zip)! Its the same format as most commercial bots, except a coupe subtle differences. Instead of !roll to finish your rolls, use !result. I did this because bebot comes with a built in !roll command. Also, because this is for org raids, I made a mode to allow people to include themselves into as many rolls as they want. Default is the more standard single roll per person, which can be changed by !mode multi, or !mode single. I hope you enjoy!
Title: Custom modules
Post by: Lal on April 07, 2005, 02:29:19 pm
its only unafking when talking in privgroup, not in gc
Title: Custom modules
Post by: craized on April 07, 2005, 06:27:30 pm
Sorry, thank you, like I said, I can't test any of the guild commands as my bot is raid only. Here's the fix, I'll upload the new version when I get home.

EDIT: Changes made, cleaning house.
http://www.craized.net/junk/bebot/modules/AFK.zip
Title: Custom modules
Post by: craized on April 07, 2005, 06:53:33 pm
Made some changes based on an old request I forgot about to my teams module, bot admins can now /tell <botname> !showmeteams to get a list the teams in a clickable window.

EDIT: Uploaded the new teams module with these changes, get it here
http://www.craized.net/junk/bebot/modules/Teams.zip
Title: Custom modules
Post by: Lal on April 07, 2005, 10:22:48 pm
Parse error: parse error, expecting `')'' in C:\BeBot\modules\AFK.php on line 64

   function gmsg($name, $this -> bot -> guildname, $msg) {


giving an error :S


            $this -> bot -> send_gc($name . "is now AFK.");
has to be:
            $this -> bot -> send_gc($name . " is now AFK.");


HMM LOL :)


and I was wondering why this was different:
. "afk(.*)/i",
. "afk(.)*/i",
Title: Custom modules
Post by: craized on April 08, 2005, 06:16:46 am
Sorry, I don't really know what I'md oing with this ><. Try changing
Code: [Select]
function gmsg($name, $this -> bot -> guildname, $msg) {
to
Code: [Select]
function gmsg($name, $group, $msg) {

Good luck and please let me know if it works.
Title: Custom modules
Post by: Lal on April 08, 2005, 02:40:00 pm
Code: [Select]
 if(strtolower($name) != $this -> bot -> botname) {

caused the chatspam...

changed to

 
Code: [Select]
  if($name != $this -> bot -> botname) {  

BUG: its not going on BACK when using a command.


ok well nothing fixed my guildchat problem, tried the GC command also umm
Code: [Select]

   function gc($name, $msg) {
               $this -> bot -> send_gc($name . " - " . $msg);

$commands["gc"][] = &$afk;
wont even work :S / going to check all { } tags now... [edit] tags are all OK [/edit]
Title: Custom modules
Post by: Lal on April 08, 2005, 03:14:22 pm
ok changed some crap and works now:

Code: [Select]

<?php 
/* 
* AFK Module for BE Bot <http://bebot.fieses.net> 
* Module coded by Craized <http://www.craized.net> 

/* 
Add a "_" at the beginning of the file (_AFK.php) if you do not want it to be loaded. 
*/ 

$afk = new AFK($bot); 

$commands["pgmsg"][] = &$afk
$commands["gmsg"][$guild_name][] = &$afk

Class 
AFK 
   var 
$bot
   var 
$afk

   function 
AFK(&$bot) { 
      
$this -> bot = &$bot
      
$this -> afk = array(); 
   } 

   function 
gone($name$msg) { 
      if(!
$msg) { 
         
$msg "Away from keyboard"
      } 
      
$this -> afk[$name] = $msg
   } 

   function 
back($name) { 
      if(
$this -> afk[$name]) { 
         unset(
$this -> afk[$name]); 
      } 
   } 

   function 
acheck($name) { 
      if(
$this -> afk[$name]) { 
         return 
true
         } else { 
         return 
false
      } 
   } 

   function 
pgmsg($name$msg) { 
      if(
$name != $this -> bot -> botname) { 
         if(
preg_match("/^" $this -> bot -> commpre "afk(.*)/i"$msg$afkmsg)) { 
            
$this -> gone($name$afkmsg[1]); 
            
$this -> bot -> send_pgroup($name " is now AFK."); 
            } else if(
$this -> acheck($name)) { 
            
$this -> back($name); 
            
$this -> bot -> send_pgroup($name " is back."); 
            } else { 
            foreach(
$this -> afk as $key=>$value) { 
               if(
preg_match("#$key\b#i"$msg)) { 
                  
$this -> bot -> send_pgroup($key " is AFK (" $value ")"); 
               } 
            } 
         } 
      } 
   } 

   function 
gmsg($name$group$msg) { 
      if(
$name != $this -> bot -> botname) {
         if(
preg_match("/^" $this -> bot -> commpre "afk(.)*/i"$msg$afkmsg)) { 
            
$this -> gone($name$afkmsg[1]); 
            
$this -> bot -> send_gc($name " is now AFK."); 
            } else if(
$this -> acheck($name)) { 
            
$this -> back($name); 
            
$this -> bot -> send_gc($name " is back."); 
            } else { 
            foreach(
$this -> afk as $key=>$value) { 
               if(
preg_match("/$key\b/i"$msg)) { 
                  
$this -> bot -> send_gc($key " is AFK (" $value ")"); 
               } 
            } 
         } 
      } 
   } 


?>



and please explain me...
Code: [Select]

         if(preg_match("/^" . $this -> bot -> commpre . "afk(.)*/i", $msg, $afkmsg)) {

    if(preg_match("#$key\b#i", $msg)) {

what changes?
Code: [Select]

         if(preg_match("/^" . $this -> bot -> commpre . "afk(.*)/i", $msg, $afkmsg)) {

               if(preg_match("/$key\b/i", $msg)) {
Title: Custom modules
Post by: Lal on April 08, 2005, 03:17:59 pm
but the !online thingy is bugged and it showed -1 in one of my alts (also the old version)
and when doing !alts ONLY MY NAME, noone else the bot floods this in the log:

Code: [Select]

Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
Read error: EOF
[2005-04-08 13:23:15]   [TELL]  [OUT]   -> Lalsoldier: Lalsoldier's alts: [link]
Alts[/link]
Read error: EOF
[2005-04-08 13:23:15]   [CONN]  [ERROR] Bot has disconnected. Reconnecting in 60
 seconds.


and this is my database showing:
Code: [Select]


      id               main  
      603892205 768689656
      652080875 768689656
      746096756 768689656
      671371013 768689656
      703528182 768689656
      785129281 768689656
      667880473 768689656
      835137222 879931063
      827687062 879931063
      937554214 879931063
      905695286 785139791
      914083315 785139791
      950391956 785139791
      798965241 785139791
      835138323 785139791
      860543142 904899648
      905695310 904899648
      920394703 904899648
      864206261 904899648
      849690694 785139791
      820153541 785139791
      934904522 904899648
      945234846 862199310
(my number is 768689656) with 7 alts added.
Title: Custom modules
Post by: craized on April 08, 2005, 06:46:20 pm
Code: [Select]
 if(strtolower($name) != $this -> bot -> botname) {
change this to
Code: [Select]
 if($name != ucfirst($this -> bot -> botname)) {
Stupid people like me didn't capitalize their bot name in the bot config, so this should fix that problem for everyone.

Quote

and please explain me...
Code: [Select]
if(preg_match("/^" . $this -> bot -> commpre . "afk(.)*/i", $msg, $afkmsg)) {

    if(preg_match("#$key\b#i", $msg)) {
 

what changes?
Code: [Select]
if(preg_match("/^" . $this -> bot -> commpre . "afk(.*)/i", $msg, $afkmsg)) {

               if(preg_match("/$key\b/i", $msg)) {



afk(.)* will put each character after afk into its own part of an array, where afk(.*) will put everything after afk into into the variable $afkmsg[1]


I hope I didn't miss any of your questions, as for the Alts problem, I would either download a new version of Online.php and I'll add the modifications for you, or ask Blondengy. I don't touch any of the databases either at this point, the existing code for this bot that works fine I don't touch very much.

Good luck.
Title: Custom modules
Post by: Lal on April 08, 2005, 09:52:19 pm
hmmm ok thanks so it should be "afk(.*)/i",  for both.

what about these?

if(preg_match("#$key\b#i", $msg)) {
if(preg_match("/$key\b/i", $msg)) {
Title: Custom modules
Post by: craized on April 09, 2005, 08:18:16 am
Both are exactly the same, I just used two different delimiters. For regex, every expression starts and ends with a specific characters so that PHP knows where it starts and ends. At one point, I wasn't sure if # was screwing it up, so I switched to the more common / and never switched it back. You can either leave it, or make it more uniform, all up to you.
Title: Custom modules
Post by: Lal on April 09, 2005, 08:52:39 am
OK Thanks craized,

Fixed a few spaces and stuff and added !afk in tells now.

Code: [Select]
<?php 
/* 
* AFK Module for BE Bot <http://bebot.fieses.net> 
* Module coded by Craized <http://www.craized.net> 

/* 
Add a "_" at the beginning of the file (_AFK.php) if you do not want it to be loaded. 
*/ 

$afk = new AFK($bot); 

$commands["tell"]["afk"] = &$afk;
$commands["privgroup"][] = &$afk
$commands["gmsg"][$guild_name][] = &$afk

Class 
AFK 
   var 
$bot
   var 
$afk

   function 
AFK(&$bot) { 
      
$this -> bot = &$bot
      
$this -> afk = array(); 
   } 

   function 
gone($name$msg) { 
      if(!
$msg) { 
         
$msg "Away from keyboard"
      } 
      
$this -> afk[$name] = $msg
   } 

   function 
back($name) { 
      if(
$this -> afk[$name]) { 
         unset(
$this -> afk[$name]); 
      } 
   } 

   function 
acheck($name) { 
      if(
$this -> afk[$name]) { 
         return 
true
         } else { 
         return 
false
      } 
   } 

   function 
tell($name$msg) { 
       if(
preg_match("/^" $this -> bot -> commpre "afk (.*)/i"$msg$afkmsg)) { 
          
$this -> gone($name$afkmsg[1]); 
          
$this -> bot -> send_gc($name " is now AFK."); 
       } 
   

 
   function 
privgroup($name$msg) { 
      if(
$name != $this -> bot -> botname) { 
         if(
preg_match("/^" $this -> bot -> commpre "afk (.*)/i"$msg$afkmsg)) { 
            
$this -> gone($name$afkmsg[1]); 
            
$this -> bot -> send_pgroup($name " is now AFK."); 
            } else if(
$this -> acheck($name)) { 
            
$this -> back($name); 
            
$this -> bot -> send_pgroup($name " is back."); 
            } else { 
            foreach(
$this -> afk as $key=>$value) { 
               if(
preg_match("/$key\b/i"$msg)) { 
                  
$this -> bot -> send_pgroup($key " is AFK (" $value ")."); 
               } 
            } 
         } 
      } 
   } 

   function 
gmsg($name$group$msg) { 
      if(
$name != $this -> bot -> botname) { 
         if(
preg_match("/^" $this -> bot -> commpre "afk (.*)/i"$msg$afkmsg)) { 
            
$this -> gone($name$afkmsg[1]); 
            
$this -> bot -> send_gc($name " is now AFK."); 
            } else if(
$this -> acheck($name)) { 
            
$this -> back($name); 
            
$this -> bot -> send_gc($name " is back."); 
            } else { 
            foreach(
$this -> afk as $key=>$value) { 
               if(
preg_match("/$key\b/i"$msg)) { 
                  
$this -> bot -> send_gc($key " is AFK (" $value ")."); 
               } 
            } 
         } 
      } 
   }


?>


I also made the teams module easier to read ingame, other style like [Lalsoldier] - [Lal] and fixed some cases where name wouldnt be should be Bebot and was bebot.

I also made it clear from non-LFT when leaving the bot now.

Code: [Select]
<?php 
/* 
* Teams Module for BE Bot <http://bebot.fieses.net> 
* Module coded by Craized <http://www.craized.net> 

/* 
Add a "_" at the beginning of the file (Teams.php) if you do not want it to be loaded. 
*/ 

$teams = new Teams($bot); 
$commands["tell"]["teams"] = &$teams
$commands["pgmsg"]["teams"] = &$teams
$commands["pgjoin"][] = &$teams
$commands["pgleave"][] = &$teams

/* 
The Class itself... 
*/ 
class Teams 
   var 
$bot
   var 
$pgroup

   
/* 
   Constructor: 
   Hands over a referance to the "Bot" class. 
   */ 
   
function Teams (&$bot) { 
      
$this -> bot = &$bot
      
$this -> autonum true
   } 

   function 
tell($name$msg) { 
   
  $color1 "<font color=#FF0000>"
$color2 "<font color=#9999CC>"
      if(
$this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) { 
      if(
$this -> autonum == true) { 
         
$numteams $this -> teams
         } else { 
         
$numteams $this -> numteam
      }             
         for(
$num=1$num<=$numteams$num++) { 
            
$result .= $color1 "Team " $num ": "
            
$count count($this -> team[$num]); 
            
$membnum 1
            for(
$spot=1$spot<=$count$spot++) { 
               if(
$this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") { 
                  if(
$membnum == 1) { 
                     
$result .= "[" $this -> team[$num][$spot] . "]"
                     }   else { 
                     
$result .= " - [" $this -> team[$num][$spot] . "]"
                  } 
                  
$membnum++; 
               }
            } 
            if (
$membnum == 1) { $result .= "None"; } 
            
$result .= "\n"
         } 
         
$result .= $color1 "Unteamed: "
         unset(
$unteamed); 
         
$players 1;
         foreach(
$this -> pgroup as $player=>$team) { 
            if(
$team == "lft") { 
            
if($players == 1) { 
               
$result .= "[" $player "]"
               
$players++;
              } else {
               
$result .= " - [" $player "]"
              }
               
$unteamed true
            } 
         }
         
if ($players == 1) { $result .= "None"; }
            
$result $this -> bot -> make_blob("Show teams"$result); 
            
$this -> bot -> send_tell($name$result); 
            unset(
$result); 
      } 
   } 

   
/* 
   This gets called on a msg in the privgroup with the command 
   */ 
   
function pgmsg($name$msg)   { 
   
  $color1 "<font color=#FF0000>"
$color2 "<font color=#9999CC>"
      
$msg explode(" "$msg); 
      if(
$this -> autonum == true) { 
         
$numteams $this -> teams
         } else { 
         
$numteams $this -> numteam
      } 
      if (
$msg[1] == "") { 
         for(
$num=1$num<=$numteams$num++) { 
            
$result .= $color1 "Team " $num ": "
            
$count count($this -> team[$num]); 
            
$membnum 1
            for(
$spot=1$spot<=$count$spot++) { 
               if(
$this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") { 
                  if(
$membnum == 1) { 
                     
$result .= "[" $this -> team[$num][$spot] . "]";
                     } else { 
                     
$result .= " - [" $this -> team[$num][$spot] . "]"
                  } 
                  
$membnum++; 
               } 
            } 
            if (
$membnum == 1) { $result .= "None"; }
            
$this -> bot -> send_pgroup($result); 
            unset(
$result); 
         } 
         
$result .= $color1 "Unteamed: "
         unset(
$unteamed); 
         
$players 1;
         foreach(
$this -> pgroup as $player=>$team) { 
            if(
$team == "lft") { 
              if(
$players == 1) { 
               
$result .= "[" $player "]"
               
$players++;
              } else {
               
$result .= " - [" $player "]"
              }
               
$unteamed true
           

         } 
          
if ($players == 1) { $result .= "None"; }
            
$this -> bot -> send_pgroup($result); 
      } 
      if(
$msg[1] == "clear") { 
         if(
$this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) { 
            foreach(
$this -> pgroup as $player=>$value) { 
         if(
$this -> left[$player]) { 
            unset(
$this -> pgroup[$player]); 
         } else { 
         
$this -> pgroup[$player] = "lft"
      } 
               unset(
$this -> team); 
            } 
            
$this -> bot -> send_pgroup($color2 "Teams are cleared."); 
         } 
      } 
      if(
preg_match("#^[1-9]#"$msg[1])) { 
         if(
$numteams >= $msg[1]) { 
            
$team $msg[1]; 
            
$spot count($this -> team[$team])+1
            
$count 1
            for(
$teamnum=1$teamnum <= $numteams$teamnum++) { 
               foreach(
$this -> team[$teamnum] as $key => $value) { 
                  if(
$value == $teamnum) { 
                     
$count++; 
                  } 
               } 
            } 
            if (
$count <= 6){ 
               if(
$msg[2] == "") { 
                  if(
$this -> pgroup[$name] != $team) { 
                     foreach(
$this -> team as $team1=>$spot1) { 
                        foreach(
$this -> team[$team1] as $spot1=>$spot2) { 
                           if(
$this -> team[$team1][$spot1] == $name){ 
                              
$oldspot $spot1
                              
$oldteam $team1
                           } 
                        } 
                     } 
                     
$this -> team[$oldteam][$oldspot] = "gone"
                     
$this -> team[$team][$spot] = $name
                     
$this -> pgroup[$name] = $team
                     
$this -> bot -> send_pgroup($color2 $name " is added to team " $msg[1] . "."); 
                     } else { 
                     
$this -> bot -> send_pgroup($color2 $name " is already in team " $team "."); 
                  } 
                  } else { 
                  if(
$this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) { 
                     
$user ucfirst($msg[2]); 
                     if(
$numteams >= $msg[1]) { 
                        if(
$this -> pgroup[$user]) { 
                           if(
$this -> pgroup[$user] != $team) { 
                              foreach(
$this -> team as $team1=>$spot1) { 
                                 foreach(
$this -> team[$team1] as $spot1=>$spot2) { 
                                    if(
$this -> team[$team1][$spot1] == $user){ 
                                       
$oldspot $spot1
                                       
$oldteam $team1
                                    } 
                                 } 
                              } 
                              
$this -> team[$oldteam][$oldspot] = "gone"
                              
$this -> team[$team][$spot] = $user
                              
$this -> pgroup[$user] = $team
                              
$this -> bot -> send_pgroup($color2 $user " is added to team " $msg[1] . "."); 
                              } else { 
                              
$this -> bot -> send_pgroup($color2 $user " is already in team " $team "."); 
                           } 
                           } else { 
                           
$this -> bot -> send_pgroup($color2 $user " is not in " $this -> bot -> botname "."); 
                        } 
                     } 
                  } 
               } 
               } else { 
               
$this -> bot -> send_pgroup($color2 "Team " $team " is full."); 
            } 
         } 
         } elseif(
preg_match("#^0#"$msg[1])) { 
         if(!
$msg[2]) { 
            
$user $name
            } else { 
            
$user ucfirst($msg[2]); 
         } 
         foreach(
$this -> team as $team1=>$spot1) { 
            foreach(
$this -> team[$team1] as $spot1=>$spot2) { 
               if(
$this -> team[$team1][$spot1] == $user){ 
                  
$oldspot $spot1
                  
$oldteam $team1
               } 
            } 
         } 
         
$this -> team[$oldteam][$oldspot] = "gone"
         if(
$this -> left[$user]) { 
            unset(
$this -> pgroup[$user]); 
         } else { 
         
$this -> pgroup[$user] = "lft"
      } 
         
$this -> bot -> send_pgroup($color2 $user " is added to Unteamed."); 
      } 
      if(
$msg[1] == num) { 
      if(
$this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) { 
         if(
$msg[2] == auto) { 
               
$this -> autonum true
               foreach(
$this -> pgroup as $player=>$value) { 
                  
$this -> pgroup[$player] = "lft"
                  unset(
$this -> team); 
               } 
               
$this -> bot -> send_pgroup($color2 "Teams are cleared."); 
               
$this -> bot -> send_pgroup($color2 "Maximum number of teams set to automatic."); 
               } elseif(
preg_match("#^[1-90]#"$msg[2])) { 
               
$this -> numteam $msg[2]; 
               
$this -> bot -> send_pgroup($color2 "Maximum number of teams set to " $msg[2] . "."); 
               
$this -> autonum false
            } 
         } 
      } 
   } 


   
/* 
   This gets called if someone joins the privgroup 
   */ 
   
function pgjoin($name) { 
      if(
$this -> left[$name]) { 
         unset(
$this -> left[$name]); 
      } 
      if(!
$this -> pgroup[$name]) { 
         
$this -> pgroup[$name] = "lft"
         
$this -> teams ceil(count($this -> pgroup)/6); 
      } 
   } 



   
/* 
   This gets called if someone leaves the privgroup 
   */ 
   
function pgleave($name) { 
   
foreach($this -> team as $team1=>$spot1) { 
   
foreach($this -> team[$team1] as $spot1=>$spot2) { 
   
if($this -> team[$team1][$spot1] == $name){ 
   
$oldspot $spot1
   
$oldteam $team1
   

   

      } 
      unset(
$this -> pgroup[$name]); 
      if (
$this -> pgroup[$name] != "lft") { 
      
$this -> team[$oldteam][$oldspot] = "gone";  
   

   } 

?>
Title: Custom modules
Post by: craized on April 09, 2005, 10:53:26 am
Thank you Lal, I'll update the file I uploaded and give you some credit for all your help!
Title: Custom modules
Post by: Lal on April 09, 2005, 10:58:19 am
Quote from: "craized"
Thank you Lal, I'll update the file I uploaded and give you some credit for all your help!

oh lets PvP clammer =)
Title: Teams module
Post by: Zacix on April 13, 2005, 02:18:53 pm
Took the liberty of changing the teammodule. I have no clue how PHP really works so forgice the coding, but I think I made a nice feature rewrite. I removed the !showmeteams command, and added /tell <botname> !teams admin. Should make it abit easier to make teams and makes a good replacement for !showmeteams. Also, fixed a bug (seemed to be at least) that when someone leaves the bot, the teams weren't cleaned properly. Feel free to use it :)
Code: [Select]
<?php
/*
* Teams Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>

/*
Add a "_" at the beginning of the file (Teams.php) if you do not want it to be loaded.
*/

$teams = new Teams($bot);
$commands["tell"]["teams"] = &$teams;
$commands["pgmsg"]["teams"] = &$teams;
$commands["pgjoin"][] = &$teams;
$commands["pgleave"][] = &$teams;

/*
The Class itself...
*/
class Teams {
var $bot;
var $pgroup;


/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Teams (&$bot) {
$this -> bot = &$bot;
$this -> autonum true;
}

function tell($name$msg) {
$msg explode(" "$msg);
$red "<font color=#FF0000>";
$blue "<font color=#9999CC>";
$yellow "<font color=#ffff00>";

if($this -> autonum == true) {
$numteams $this -> teams;

else {
$numteams $this -> numteam;
}
if($msg[1] == "admin"){
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
$result .= $yellow ":::: Teams Administration ::::</font><font color=#0000dd44>\n\n";
$result .= "Commands:\n";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams admin'>Refresh Teams Administration</a>\n";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams'>Show Teams</a>\n";
$result .= "Set Number of Teams <a href='chatcmd:///tell <botname> <pre>teams num auto'>Auto</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 1'>1</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 2'>2</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 3'>3</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 4'>4</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 5'>5</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 6'>6</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 7'>7</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 8'>8</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 9'>9</a>\n\n";
for($num=1$num<=$numteams$num++) {
$result .= $red $num ": LDR ";
$count count($this -> team[$num]);
$membnum 1;
for($spot=1$spot<=$count$spot++) {
if($this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") {
if($membnum == 1) {
$result .= "<a href='chatcmd:///tell <botname> <pre>teams 0 " $this -> team[$num][$spot] . "'>" $this -> team[$num][$spot] . "</a></font>";
}
else {
$result .= " - " $membnum "." "<a href='chatcmd:///tell <botname> <pre>teams 0 " $this -> team[$num][$spot] . "'>" $this -> team[$num][$spot] . "</a>";
}
$membnum++;
}
}
$result .= "\n";
}
$result .= $red "Unteamed: </font>\n";
unset($unteamed);
foreach($this -> pgroup as $player=>$team) {
if($team == "lft") {
$result .= "~" $player "~ ";
$result .= "Add to team: ";
for($num=1$num<=$numteams$num++) {
$result .=  "<a href='chatcmd:///tell <botname> <pre>teams " $num " " $player "'>" $num "</a> ";
}
$result .= "\n";
$unteamed true;
}
}
$result $this -> bot -> make_blob("Teams Administration"$result);
$this -> bot -> send_tell($name$result);
unset($result);
}
}
if ($msg[1] == "") {
for($num=1$num<=$numteams$num++) {
$result .= $red $num ": LDR ";
$count count($this -> team[$num]);
$membnum 1;
for($spot=1$spot<=$count$spot++) {
if($this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") {
if($membnum == 1) {
$result .= $this -> team[$num][$spot] . "</font>";
}
else {
$result .= " - " $membnum "." $this -> team[$num][$spot];
}
$membnum++;
}
}
$this -> bot -> send_pgroup($result);
unset($result);
}
$result .= $red "Unteamed: ";
unset($unteamed);
foreach($this -> pgroup as $player=>$team) {
if($team == "lft") {
$result .= "~" $player "~ ";
$unteamed true;
}
}
if($unteamed) {
$this -> bot -> send_pgroup($result);
}
}
if($msg[1] == "clear") {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
foreach($this -> pgroup as $player=>$value) {
if($this -> left[$player]) {
unset($this -> pgroup[$player]);

else {
$this -> pgroup[$player] = "lft";
}
unset($this -> team);
}
$this -> bot -> send_pgroup($blue "Teams cleared");
}
}
if(preg_match("#^[1-9]#"$msg[1])) {
if($numteams >= $msg[1]) {
$team $msg[1];
$spot count($this -> team[$team])+1;
$count 1;
for($teamnum=1$teamnum <= $numteams$teamnum++) {
foreach($this -> team[$teamnum] as $key => $value) {
if($value == $teamnum) {
$count++;
}
}
}
if ($count <= 6){
if($msg[2] == "") {
if($this -> pgroup[$name] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $name){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $name;
$this -> pgroup[$name] = $team;
$this -> bot -> send_pgroup($blue $name " assigned to team " $msg[1]);
}
else {
$this -> bot -> send_pgroup($blue " " $name " already in team " $team);
}
}
else {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
$user ucfirst($msg[2]);
if($numteams >= $msg[1]) {
if($this -> pgroup[$user]) {
if($this -> pgroup[$user] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $user;
$this -> pgroup[$user] = $team;
$this -> bot -> send_pgroup($blue $user " assigned to team " $msg[1]);

else {
$this -> bot -> send_pgroup($blue $user " already in team " $team);
}
}
else {
$this -> bot -> send_pgroup($blue $msg[2] . " not in " $this -> bot -> botname);
}
}
}
}

else {
$this -> bot -> send_pgroup($blue "Sorry, team " $team " is full.");
}
}
}
 elseif(preg_match("#^0#"$msg[1])) {
if(!$msg[2]) {
$user $name;
}
else {
$user ucfirst($msg[2]);
}
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
if($this -> left[$user]) {
unset($this -> pgroup[$user]);

else {
$this -> pgroup[$user] = "lft";
}
$this -> bot -> send_pgroup($blue $user " cleared from teams.");
}
if($msg[1] == num) {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
if($msg[2] == auto) {
$this -> autonum true;
foreach($this -> pgroup as $player=>$value) {
$this -> pgroup[$player] = "lft";
unset($this -> team);
}
$this -> bot -> send_pgroup($blue "Teams cleared");
$this -> bot -> send_pgroup($blue "Automatic teams now enabled");

elseif(preg_match("#^[1-90]#"$msg[2])) {
$this -> numteam $msg[2];
$this -> bot -> send_pgroup($blue "Maximum number of teams now set to " $msg[2]);
$this -> autonum false;
}
}
}
}

/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name$msg) {
$msg explode(" "$msg);
$red "<font color=#FF0000>";
$blue "<font color=#9999CC>";
if($this -> autonum == true) {
$numteams $this -> teams;

else {
$numteams $this -> numteam;
}
if ($msg[1] == "") {
for($num=1$num<=$numteams$num++) {
$result .= $red $num ": LDR ";
$count count($this -> team[$num]);
$membnum 1;
for($spot=1$spot<=$count$spot++) {
if($this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") {
if($membnum == 1) {
$result .= $this -> team[$num][$spot];
} else {
$result .= " - " $membnum "." $this -> team[$num][$spot];
}
$membnum++;
}
}
$this -> bot -> send_pgroup($result);
unset($result);
}
$result .= $red "Unteamed: ";
unset($unteamed);
foreach($this -> pgroup as $player=>$team) {
if($team == "lft") {
$result .= "~" $player "~ ";
$unteamed true;
}
}
if($unteamed) {
$this -> bot -> send_pgroup($result);
}
}
if($msg[1] == "clear") {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
foreach($this -> pgroup as $player=>$value) {
if($this -> left[$player]) {
unset($this -> pgroup[$player]);
} else {
$this -> pgroup[$player] = "lft";
}
unset($this -> team);
}
$this -> bot -> send_pgroup($blue "Teams cleared");
}
}
if(preg_match("#^[1-9]#"$msg[1])) {
if($numteams >= $msg[1]) {
$team $msg[1];
$spot count($this -> team[$team])+1;
$count 1;
for($teamnum=1$teamnum <= $numteams$teamnum++) {
foreach($this -> team[$teamnum] as $key => $value) {
if($value == $teamnum) {
$count++;
}
}
}
if ($count <= 6){
if($msg[2] == "") {
if($this -> pgroup[$name] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $name){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $name;
$this -> pgroup[$name] = $team;
$this -> bot -> send_pgroup($blue $name " assigned to team " $msg[1]);
} else {
$this -> bot -> send_pgroup($blue " " $name " already in team " $team);
}
} else {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
$user ucfirst($msg[2]);
if($numteams >= $msg[1]) {
if($this -> pgroup[$user]) {
if($this -> pgroup[$user] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $user;
$this -> pgroup[$user] = $team;
$this -> bot -> send_pgroup($blue $user " assigned to team " $msg[1]);
} else {
$this -> bot -> send_pgroup($blue $user " already in team " $team);
}
} else {
$this -> bot -> send_pgroup($blue $msg[2] . " not in " $this -> bot -> botname);
}
}
}
}
} else {
$this -> bot -> send_pgroup($blue "Sorry, team " $team " is full.");
}
}
} elseif(preg_match("#^0#"$msg[1])) {
if(!$msg[2]) {
$user $name;
} else {
$user ucfirst($msg[2]);
}
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
if($this -> left[$user]) {
unset($this -> pgroup[$user]);
} else {
$this -> pgroup[$user] = "lft";
}
$this -> bot -> send_pgroup($blue $user " cleared from teams.");
}
if($msg[1] == num) {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
if($msg[2] == auto) {
$this -> autonum true;
foreach($this -> pgroup as $player=>$value) {
$this -> pgroup[$player] = "lft";
unset($this -> team);
}
$this -> bot -> send_pgroup($blue "Teams cleared");
$this -> bot -> send_pgroup($blue "Automatic teams now enabled");
} elseif(preg_match("#^[1-90]#"$msg[2])) {
$this -> numteam $msg[2];
$this -> bot -> send_pgroup($blue "Maximum number of teams now set to " $msg[2]);
$this -> autonum false;
}
}
}
}


/*
This gets called if someone joins the privgroup
*/
function pgjoin($name) {
if($this -> left[$name]) {
unset($this -> left[$name]);
}
if(!$this -> pgroup[$name]) {
$this -> pgroup[$name] = "lft";
$this -> teams ceil(count($this -> pgroup)/6);
}
}



/*
This gets called if someone leaves the privgroup
*/
function pgleave($name) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $name){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
/*if($this -> left[$user]) {
unset($this -> pgroup[$user]);

else {
$this -> pgroup[$user] = "lft";
}*/
$this -> pgroup[$name] = "lft";
if ($this -> pgroup[$name] == "lft") {
unset($this -> pgroup[$name]);

else {
$this -> left[$name] = true;
}
}
}
?>
Title: !admin del $playername
Post by: Zacix on April 13, 2005, 02:28:23 pm
This command has an error. It allows an admin to remove a superadmin. The problem is in the member_del function (depending on how the command is done, sometimes group = all, hence the error occurs). The first part of the function should be something like this:

Code: [Select]

function member_del($name, $group, $member)
{
      $group = strtolower($group);

        if($this -> in_group($member, "superadmin"))
return "Hey stupid!, Don't mess with the superadmins!";
        if($this -> in_group($member, "admin"))
$need_group = "superadmin";
        else
$need_group = "admin";

Title: Custom modules
Post by: craized on April 14, 2005, 08:13:45 am
Per request, I have made it possible to set a highlight color so to speak through your Bot.conf file. All my modules will now use this color if its set, otherwise I've set another color to highlight with. In order for this to work, download these moded files (http://www.craized.net/junk/bebot/modules/MOD.zip) and replace your current versions. I included Bot.conf as well with the extra value, but I suggest just adding in the line $highlight_color = "#FF0000";(or any color) to your pre-existing files.

On top of this, I'm releasing a new version of my Loot module (http://www.craized.net/junk/bebot/modules/Loot.zip) with better formatting, and a new Teams module (http://www.craized.net/junk/bebot/modules/Teams.zip) Lal and I have been working on together. It actually does include some of the changes Zacix has made himself, purely by coincidence, !showmeteams has been changed to !teams, there are now two modes. !teams mode stay, and !teams mode kick. Stay mode will keep users in the teams setup after they leave the bot (My prefered setup to help prevent confusion with LD etc.), and kick mode, where users will be kicked from the teams setup upon exit of the bot.
Title: Re: !admin del $playername
Post by: craized on April 14, 2005, 08:16:41 am
Quote from: "Zacix"
This command has an error. It allows an admin to remove a superadmin. The problem is in the member_del function (depending on how the command is done, sometimes group = all, hence the error occurs). The first part of the function should be something like this:

Code: [Select]

function member_del($name, $group, $member)
{
      $group = strtolower($group);

        if($this -> in_group($member, "superadmin"))
return "Hey stupid!, Don't mess with the superadmins!";
        if($this -> in_group($member, "admin"))
$need_group = "superadmin";
        else
$need_group = "admin";




Code: [Select]

    function member_del($name, $group, $member)
    {
      $group = strtolower($group);
      if (($group == "admin") || ($group == "superadmin"))
        $need_group = "superadmin";
      else
        $need_group = "admin";


This means that if the user is trying to delete an admin or a superadmin, then they need to be a superadmin, otherwise, they need to be an admin. This does not allow users in the admin group to delete superadmins.

Also, this is the wrong thread for this.  :)
Title: Re: !admin del $playername
Post by: Zacix on April 14, 2005, 09:47:00 am
Quote from: "craized"

Code: [Select]

    function member_del($name, $group, $member)
    {
      $group = strtolower($group);
      if (($group == "admin") || ($group == "superadmin"))
        $need_group = "superadmin";
      else
        $need_group = "admin";


This means that if the user is trying to delete an admin or a superadmin, then they need to be a superadmin, otherwise, they need to be an admin. This does not allow users in the admin group to delete superadmins.

Also, this is the wrong thread for this.  :)


This is true, but u could do !tell <botname> !admin del <username>. In this case group = all (the option where u want to delete the user from all groups). If the <username> is a superadmin and the user that tries to delete the superadmin is just an admin, it will work perfectly well since the code checks the $group against "admin" and "superadmin". Therefore, in my opinion, it's more bulletproof and versatile to check if the user you are trying to delete is in a specific group rather than using the groupname entered.

I do understand the old code btw, and it does not work :) Only difference with my code is that you can't delete superadmins online. Superadmins will have to be removed from the setupfiles anyway. To make the code the same as yours was intended to be, just remove the first if block.

If u want to check that the old logic doesn't work, make an admin do a /tell <botname> !admin del <superadmin>

Sowwy for using the wrong thread btw and big thx to you guys that's making this a really good bot :)
Title: Custom modules
Post by: Zarkingu on April 14, 2005, 09:05:15 pm
Love those modules craized.

As I'm a complete beginner in the PHP bussines I was wondering how to change this code from the timer module.

function cron()
   {
      $timeleft = $this -> timer -> time-mktime();
      if($timeleft <= 0 && $this -> timer -> active == "on") {
         $this -> bot -> send_pgroup($highlight . $this -> timer -> user . " your timer has gone off.");
         unset($this -> timer);
      }
   }


As it is now it will display this in chat when timer is up.
Somecharacter your timer has gone off

What I would like is something like this
TIMER UP!! ITS ON!!

Tried editing it, but got a parse error. Think I might have cut off too much of the code.
Title: Custom modules
Post by: craized on April 14, 2005, 11:38:27 pm
Code: [Select]

function cron()
{
$timeleft = $this -> timer -> time-mktime();
if($timeleft <= 0 && $this -> timer -> active == "on") {
$this -> bot -> send_pgroup("TIMER UP!! ITS ON !!");
unset($this -> timer);
}
}


That should work :)
Title: Custom modules
Post by: Lal on April 15, 2005, 08:26:25 am
Code: [Select]
$this -> timer -> time = mktime()+$msg[1]*60;
$this -> bot -> send_pgroup("Timer set for " . $highlight . $msg[1] . " minutes");
} elseif($msg[1] == clear) {


change this to

Code: [Select]
$this -> timer -> time = mktime()+$msg[1]*60;
$this -> bot -> send_pgroup("ITS ON!!!");
} elseif($msg[1] == clear) {
Title: Custom modules
Post by: craized on April 15, 2005, 08:48:47 am
Oop ><

Bad bug in my loot module, whoever joins the role first wins. Updated code here, I'll upload asap.

Thanks to Zacix for fixing a bug in the single loot mode.

Code: [Select]

<?
/*
* Loot Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>

/*
Add a "_" at the beginning of the file (_Loot.php) if you do not want it to be loaded.
*/

$loot = new Rolls($bot);


$commands["tell"]["rem"] = &$loot;
$commands["tell"]["add"] = &$loot;
$commands["pgmsg"]["loot"] = &$loot;
$commands["pgmsg"]["add"] = &$loot;
$commands["pgmsg"]["rem"] = &$loot;
$commands["pgmsg"]["result"] = &$loot;
$commands["pgmsg"]["mode"] = &$loot;
$commands["pgmsg"]["list"] = &$loot;
$commands["pgmsg"]["clear"] = &$loot;

/*
The Class itself...
*/
class Rolls {
var $bot;

/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Rolls (&$bot) {
$this -> bot = &$bot;
$this -> mode = "multi";
if(!$this -> bot -> highlight_color) {
$this -> highlight = "<font color=#CB11C9>";
} else {

$this -> highlight = "<font color=" . $this -> bot -> highlight_color . ">";
}
}

/*
This gets called on a tell with the command
*/
function tell($name, $msg) {
$highlight = $this -> highlight;
if(preg_match("/^" . $this -> bot -> commpre . "rem ([0-9]+)/i", $msg, $info)) {
unset($this -> loot[$info[1]][$name]);
$this -> bot -> send_pgroup($highlight . $name . "</font> removed from rolls in slot$highlight #" . $info[1]);
$this -> bot -> send_tell($name, $highlight . $name . " </font>removed from rolls in slot$highlight #" . $info[1]);
}
if(preg_match("/^" . $this -> bot -> commpre . "add ([0-9]+)/i", $msg, $info)) {
$this -> add($name, $info[1]);
$this -> bot -> send_tell($name, $this -> addmsg);
}
}

/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg) {
$highlight = $this -> highlight;
if(preg_match("/^" . $this -> bot -> commpre . "loot (.*)/i", $msg, $info)) {
$this -> loot($info[1], $name);
}
if(preg_match("/^" . $this -> bot -> commpre . "add ([0-9]+)/i", $msg, $info)) {
$this -> add($name, $info[1]);
}
if(preg_match("/^" . $this -> bot -> commpre . "list/i", $msg)) {
$this -> rlist();
}
if(preg_match("/^" . $this -> bot -> commpre . "mode ?(.*)/i", $msg, $info)) {
if(!$info[1]) {
$this -> bot -> send_pgroup("Loot mode currently set to$highlight " . $this -> mode . "</font>.");
}
if(!$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name, "raidleader") || $this -> bot -> admin -> in_group($name, "admin")) {
if(!$this -> lead) {
if($info[1] == single) {
$this -> mode = "single";
$this -> bot -> send_pgroup("Roll mode changed to$highlight single loot</font>.");
} else if($info[1] == multi) {
$this -> mode = "multi";
$this -> bot -> send_pgroup("Roll mode changed to$highlight multiple loot</font>.");
}
} else {
$this -> bot -> send_pgroup("You cannot change the loot mode while rolling is in progress.");
}
}
}

if(preg_match("/^" . $this -> bot -> commpre . "rem ([0-9]+)/i", $msg, $info)) {
unset($this -> loot[$info[1]][$name]);
$this -> bot -> send_pgroup($highlight . $name . "</font> removed from rolls in slot$highlight #" . $info[1]);
}
if(preg_match("/^" . $this -> bot -> commpre . "result/i", $msg)) {
if($this -> lead == $name || !$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name, "raidleader") || $this -> bot -> admin -> in_group($name, "admin")) {
$this -> roll($name);
}
}
if(preg_match("/^" . $this -> bot -> commpre . "clear/i", $msg)) {
if($this -> lead == $name || !$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name, "raidleader") || $this -> bot -> admin -> in_group($name, "admin")) {
unset($this -> loot);
unset($this -> lead);
$this -> bot -> send_pgroup("<font color=#FF0000>" . $name . " cancelled the loot rolls in progress");
}
}
}

function add($name, $slot) {
$highlight = $this -> highlight;
unset($present);
if($this -> loot[$slot]) {
if($this -> mode == 'single') {
$slots = array_keys($this -> loot);
foreach($slots as $key=>$sslot) {
$list = array_keys($this -> loot[$sslot]);
foreach($list as $playerslot=>$player) {
if($player == $name) {
unset($this -> loot[$sslot][$player]);
$present = true;
}
}
}
if($present == true) {
$this -> addmsg = $highlight . "$name</font> changed to slot$highlight #$slot</font>";
} else {
$this -> addmsg = $highlight . "$name</font> assigned to slot$highlight #$slot</font>";
}
$this -> loot[$slot][$name] = true;
} else {
$this -> loot[$slot][$name] = true;
$this -> addmsg = $highlight . "$name</font> assiged to slot$highlight #$slot</font>";
}
} else {
$this -> addmsg = "There is currently no roll in slot $slot";
}
$this -> bot -> send_pgroup($this -> addmsg);
}

function loot($msg, $name) {
$highlight = $this -> highlight;
if($this -> lead == $name || !$this -> lead) {
$this -> lead = $name;
$count = count($this -> loot)+1;
$this -> loot[$count][item] = $msg;
$this -> bot -> send_pgroup($highlight . $msg . "</font> being rolled in slot$highlight #" . $count);
}
}

function roll($name){
$highlight = $this -> highlight;
$num = 1;
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name, "raidleader") || $this -> bot -> admin -> in_group($name, "admin") || $this -> lead == $name || !$this -> lead) {
foreach($this -> loot as $slot) {
unset($winner);
$users = array();
$item = $slot[item];
unset($slot[item]);
$list = $slot;
$users = array_keys($slot);
$rolling = $users;
$count = count($slot)-1;
for($i = 1; $i <= 10000; $i++) {
$list[$users[rand(0, $count)]] += 1;
}
natsort($list);
foreach($list as $name => $points) {
$winner = $name;
}
if(!$winner) {
$winner = Nobody;
}
$this -> bot -> send_pgroup($highlight . $winner . " </font>won the roll for$highlight " . $item . " </font>in slot$highlight #" . $num . "!");
unset($this -> loot[$num]);
unset($this -> lead);
$num++;
}
}
}

function rlist() {
$highlight = $this -> highlight;
$num = 0;
foreach($this -> loot as $slot) {
unset($msg);
$num++;
$msg .= "Rolling on item$highlight $slot[item]</font> in slot$highlight #$num</font>:";
if(count($slot) == 1) {
$msg .= $highlight . " Nobody included";
} else {
$list = array_keys($slot);
foreach($list as $key=>$player) {
if($player != "item") {
$msg .= "$highlight [$player]</font>";
}
}
}
$this -> bot -> send_pgroup($msg);
}
}
}
?>
Title: Custom modules
Post by: craized on April 15, 2005, 10:55:24 am
More spam, but I'm proud to announce that my Alien Playfield Module is ready for re-release. Its held stead through 4 alien playfields opening up at an interval of 7 hours 12 minutes and 2.5 seconds. I'll upload when I get a chance, same as usual.

Code: [Select]

<?php
/*
* Playfield Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>

/*
Add a "_" at the beginning of the file (_Playfield.php) if you do not want it to be loaded.
*/

$playfield = new Playfield($bot);

$commands["tell"]["pf"] = &$playfield;
$commands["pgmsg"]["pf"] = &$playfield;
$commands["gc"]["pf"] = &$playfield;
$cron["2sec"][] = &$playfield;

/*
The Class itself...
*/
class Playfield {
var $bot;

/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Playfield (&$bot) {
$this -> bot = &$bot;
if($this -> bot -> highlight_color) {
$this -> highlight "<font color=" $this -> bot -> highlight_color ">";
} else {
$this -> highlight "<font color=#FFFFFF>";
}
}

/*
This gets called on a tell with the command
*/
function tell($name$msg) {
$this -> time();
$this -> bot -> send_tell($name$this -> msg);
}

/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name$msg) {
$this -> time();
$this -> bot -> send_pgroup($this -> msg);
}

/*
This gets called on a msg in the guildchat with the command
*/
function gc($name$msg) {
$this -> time();
$this -> bot -> send_gc($this -> msg);
$this -> bot -> log(GROUPSEND$this -> msg);
}

/*
This gets called on cron
*/
function cron() {
$highlight $this -> highlight;
$this -> time();
if($this -> timeleft <= 3600 && $this -> timeleft >= 3599) {
$this -> bot -> send_pgroup("<font color=#FF2222>Alien playfield is beginning in$highlight 1</font> hour!");
$this -> bot -> send_gc("<font color=#FF2222>Alien playfield is beginning in$highlight 1</font> hour!");
}
if($this -> timeleft <= 1800 && $this -> timeleft >= 1799) {
$this -> bot -> send_pgroup("<font color=#FF2222>Alien playfield is beginning in$highlight 30</font> minutes!");
$this -> bot -> send_gc("<font color=#FF2222>Alien playfield is beginning in$highlight 30</font> minutes!");
}
if($this -> timeleft <= 900 && $this -> timeleft >= 899) {
$this -> bot -> send_pgroup("<font color=#FF2222>Alien playfield is beginning in$highlight 15</font> minutes!");
$this -> bot -> send_gc("<font color=#FF2222>Alien playfield is beginning in$highlight 15</font> minutes!");
}
if($this -> timeleft <= 300 && $this -> timeleft >= 299) {
$this -> bot -> send_pgroup("<font color=#FF2222>Alien playfield is beginning in$highlight 5</font> minutes!");
$this -> bot -> send_gc("<font color=#FF2222>Alien playfield is beginning in$highlight 5</font> minutes!");
}
if($this -> timeleft <= 1) {
$this -> bot -> send_pgroup("<font color=#FF2222>Alien playfield starting$highlight now</font>!");
$this -> bot -> send_gc("<font color=#FF2222>Alien playfield starting$highlight now</font>!");
}
}

function time() {
$time gmmktime(1011454142005);
$int 7*60*60+12*60+2.5;
$raids floor((mktime()-$time)/$int);
#if(round($raids/2) == $raids/2) {
# $time = $time-1;
#}
$this -> timeleft = ($time+$int+$int*$raids)-mktime();
$timer ceil($this -> timeleft);
$h 0;
while($timer >= 3600) {
$h++;
$timer-=3600;
}
$m 0;
while($timer >= 60) {
$m++;
$timer-=60;
}
$s $timer;
if($h == 0) {
$h '00';
}
if($m 10) {
$m '0' $m;
}
if($s 10) {
$s '0' $s;
}
$this -> msg "$h:$m:$s remaining until Alien Playfield.";
}
}
?>

Title: Custom modules
Post by: Lal on April 15, 2005, 06:05:28 pm
Quote from: "craized"
More spam, but I'm proud to announce that my Alien Playfield Module is ready for re-release. Its held stead through 4 alien playfields opening up at an interval of 7 hours 12 minutes and 2.5 seconds. I'll upload when I get a chance, same as usual.


Nice, what about also finding out how long the gates are open?

Bots do log the vinicity if I remember right, so I might also be able to get everything comfirmed. (At least... IGNBot logged it somehow)
Title: Custom modules
Post by: craized on April 15, 2005, 06:38:06 pm
When you log out at the alien playfield for too long, it warps you out closer to the beacon, where vicinity will unfortunately not catch gates opening/closing. I don't know how long this timer is, but for now I spose I can just assume they're 12:025 minutes, leaving 7 hours in between the gates closing and teh gates opening. I'll update code when I get a chance.
Title: Custom modules
Post by: craized on April 20, 2005, 10:45:14 am
Updates, but I've gotten lazy and I'm tired of rezipping all of my files. You can get gauranteed up to date code(pulls straight from my bot dir) here.

http://www.craized.net/junk/bebot/highlight.php?Teams
http://www.craized.net/junk/bebot/highlight.php?Loot
http://www.craized.net/junk/bebot/highlight.php?Playfield
http://www.craized.net/junk/bebot/highlight.php?Timer

The Teams Loot and Playfield I highly recommend updating as I've found some major bugs, one of which is the Playfield timer gradually pulling away from the correct time. This may still be the case, but the best I can do is keep adjusting it until I get it right.

Thank you all for your support in this process.
Title: Teams module - Unofficial realease
Post by: Zacix on April 22, 2005, 10:37:55 am
Updated the teams module with /tell <Botname> !teams admin command and rewamped some of the code. !teams num # is now limited to 50...guess that could be changed.
Code: [Select]
<?php
/*
* Teams Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
* Special thanks to Lal for bug fixes, styles, and development
* Rewritten by Zacix

/*
Add a "_" at the beginning of the file (Teams.php) if you do not want it to be loaded.
*/


$teams = new Teams($bot);
$commands["tell"]["teams"] = &$teams;
$commands["pgmsg"]["teams"] = &$teams;
$commands["pgjoin"][] = &$teams;
$commands["pgleave"][] = &$teams;

/*
The Class itself...
*/
class Teams {
var $bot;
var $pgroup;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Teams (&$bot) {
$this -> bot = &$bot;
$this -> autonum true;
$this -> teammode stay;
if(!$this -> bot -> highlight_color) {
$this -> highlight "<font color=#CB11C9>";
}
else {
$this -> highlight "<font color=" $this -> bot -> highlight_color ">";
}
}

function tell($name$msg) {
$highlight $this -> highlight;
$msg explode(" "$msg);
if($this -> autonum == true) {
$numteams $this -> teams;
}
else {
$numteams $this -> numteam;
}

if ($msg[1] == "") {
$this->print_teams();
}
elseif(preg_match("#^[1-9]#"$msg[1])) {
$this->assign_team($name,$msg[1],$msg[2]);
}
elseif(preg_match("#^0#"$msg[1])) {
$this->remove_team($name,$msg[2]);
}
elseif($msg[1] == num) {
$this->set_num($name,$msg[2]);
}
elseif($msg[1] == "clear") {
$this->clear_team($name);
}
elseif($msg[1] == "mode") {
$this->set_mode($name,$msg[2]);
}
elseif($msg[1] == "admin") {
$this->admin_team($name,$msg[2]);
}
}

/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name$msg)   {
$highlight $this -> highlight;
$msg explode(" "$msg);
if($this -> autonum == true) {
$numteams $this -> teams;
}
else {
$numteams $this -> numteam;
}

if ($msg[1] == "") {
$this->print_teams();
}
elseif(preg_match("#^[1-9]#"$msg[1])) {
$this->assign_team($name,$msg[1],$msg[2]);
}
elseif(preg_match("#^0#"$msg[1])) {
$this->remove_team($name,$msg[2]);
}
elseif($msg[1] == num) {
$this->set_num($name,$msg[2]);
}
elseif($msg[1] == "clear") {
$this->clear_team($name);
}
elseif($msg[1] == "mode") {
$this->set_mode($name,$msg[2]);
}
}

function admin_team($name) {
$highlight $this -> highlight;
$yellow "<font color=#ffff00>";
if($this->is_allowed($name)) {
if($this -> autonum == true) {
$numteams $this -> teams;
}
else {
$numteams $this -> numteam;
}

$result .= $yellow ":::: Teams Administration ::::</font>\n\n";
$result .= $highlight "Commands:</font>\n";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams admin'>Refresh Teams Administration</a>\n";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams'>Show Teams</a>\n";
$result .= "Set Number of Teams <a href='chatcmd:///tell <botname> <pre>teams num auto'>Auto</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 1'>1</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 2'>2</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 3'>3</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 4'>4</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 5'>5</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 6'>6</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 7'>7</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 8'>8</a> ";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams num 9'>9</a>\n";
$result .= "<a href='chatcmd:///tell <botname> <pre>teams clear'>Clear Teams</a>\n\n ";

for($num=1$num<=$numteams$num++) {
$count 0;
foreach($this -> team[$num] as $player=>$value) {
if($value != "gone") {
$count++;
}
}
$result .= "Team " $num $highlight " (" $count ")</font>: ";
$count count($this -> team[$num]);
$membnum 1;
for($spot=1$spot<=$count$spot++) {
if($this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") {
$result .= "[" $this -> team[$num][$spot] . "] ";
$membnum++;
}
}
if ($membnum == 1) { $result .= $highlight "None</font>"; }
$result .= "\n";
}
$result .= $highlight "Unteamed:</font>\n";
unset($unteamed);
foreach($this -> pgroup as $player=>$team) {
if($team == "lft") {
$result .= $highlight "[" $player "] </font> ";
$result .= "Add to team: ";
for($num=1$num<=$numteams$num++) {
$result .=  "<a href='chatcmd:///tell <botname> <pre>teams " $num " " $player "'>" $num "</a> ";
}
$unteamed true;
$result .= "\n";
}
}
$result $this -> bot -> make_blob("Show teams"$result);
$this -> bot -> send_tell($name$result);
unset($result);
}
}


function is_allowed($name) {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
return true;
}
return false;
}


function set_mode($name,$mode) {
$highlight $this -> highlight;
if($this->is_allowed($name)) {
if(!$mode) {
$this -> bot -> send_pgroup("Teams mode currently set to $highlight.  $this -> teammode ".");
}
if($mode == "stay") {
$this -> teammode stay;
$this -> bot -> send_pgroup("Teams mode set to$highlight stay</font>.");
}
elseif($mode == "kick") {
$this -> teammode kick;
$this -> bot -> send_pgroup("Teams mode set to$highlight kick</font>.");
}
}
}


function clear_team($name) {
$highlight $this -> highlight;
if($this->is_allowed($name)) {
foreach($this -> pgroup as $player=>$value) {
if($this -> left[$player]) {
unset($this -> pgroup[$player]);
}
else {
$this -> pgroup[$player] = "lft";
}
unset($this -> team);
}
$this -> bot -> send_pgroup("Current teams configuration cleared by " $highlight $name "</font>.");
}
}


function set_num($name,$num) {
$highlight $this -> highlight;
if($this->is_allowed($name)) {
if($num == auto) {
$this -> autonum true;
foreach($this -> pgroup as $player=>$value) {
$this -> pgroup[$player] = "lft";
unset($this -> team);
}
$this -> bot -> send_pgroup("Maximum number of teams set to$highlight automatic</font>.");
}
elseif(preg_match("#^[1-9]$|^[1-4][0-9]$|^[1-5]0$#"$num)) {
$this -> numteam $num;
$this -> bot -> send_pgroup("Maximum number of teams set to$highlight " $num "</font>.");
$this -> autonum false;
}
}
}


function remove_team($name,$assignee) {
$highlight $this -> highlight;
if(!$assignee) {
$user $name;
}
else {
if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> admin -> in_group($name"raidleader") || $this -> bot -> admin -> in_group($name"admin")) {
$user ucfirst($assignee);
}
}
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
if($this -> left[$user]) {
unset($this -> pgroup[$user]);
}
else {
$this -> pgroup[$user] = "lft";
}
$this -> bot -> send_pgroup($highlight $user "</font> is looking for team</font>.");
}


function assign_team($name,$team,$assignee) {
$highlight $this -> highlight;
if($this -> autonum == true) {
$numteams $this -> teams;
}
else {
$numteams $this -> numteam;
}
if($numteams >= $team) {
$spot count($this -> team[$team])+1;
$count 1;
for($teamnum=1$teamnum <= $numteams$teamnum++) {
foreach($this -> team[$teamnum] as $key => $value) {
if($value == $teamnum) {
$count++;
}
}
}
if ($count <= 6){
if($assignee == "") {
if($this -> pgroup[$name] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $name){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $name;
$this -> pgroup[$name] = $team;
$this -> bot -> send_pgroup($highlight $name "</font> assigned to team " $highlight "#" $team "</font>.");
}
else {
$this -> bot -> send_pgroup($highlight $name "</font> is already in team " $highlight "#" $team "</font>.");
}
}
else {
if($this->is_allowed($name)) {
$user ucfirst($assignee);
if($numteams >= $team) {
if($this -> pgroup[$user]) {
if($this -> pgroup[$user] != $team) {
foreach($this -> team as $team1=>$spot1) {
foreach($this -> team[$team1] as $spot1=>$spot2) {
if($this -> team[$team1][$spot1] == $user){
$oldspot $spot1;
$oldteam $team1;
}
}
}
$this -> team[$oldteam][$oldspot] = "gone";
$this -> team[$team][$spot] = $user;
$this -> pgroup[$user] = $team;
$this -> bot -> send_pgroup($highlight $user "</font> assigned to team$highlight #" $team "</font>.");
}
else {
$this -> bot -> send_pgroup($highlight $user "</font> is already in team$highlight #" $team "</font>.");
}
}
else {
$this -> bot -> send_pgroup($highlight $user "</font> is not in$highlight " ucfirst($this -> bot -> botname) . "</font>.");
}
}
}
}
}
else {
$this -> bot -> send_pgroup("Team$highlight #" $team "</font> is full.");
}
}
}


function print_teams() {
$highlight $this -> highlight;
if($this -> autonum == true) {
$numteams $this -> teams;
}
else {
$numteams $this -> numteam;
}
for($num=1$num<=$numteams$num++) {
$count 0;
foreach($this -> team[$num] as $player=>$value) {
if($value != "gone") {
$count++;
}
}
$result .= "Team" $num $highlight " ($count)</font>: ";
$count count($this -> team[$num]);
$membnum 1;
for($spot=1$spot<=$count$spot++) {
if($this -> team[$num][$spot] && $this -> team[$num][$spot] != "gone") {
$result .= $highlight "[" $this -> team[$num][$spot] . "] </font>";
$membnum++;
}
}
if ($membnum == 1) { $result .= $highlight "None</font>"; }
$this -> bot -> send_pgroup($result);
unset($result);
}
$result .= "Unteamed: ";
unset($unteamed);
$players 1;
foreach($this -> pgroup as $player=>$team) {
if($team == "lft") {
$result .= $highlight "[" $player "] </font>";
$players++;
$unteamed true;
}
}
if ($players == 1) {
$result .= $highlight "None</font>";
}
$this -> bot -> send_pgroup($result);
}

/*
This gets called if someone joins the privgroup
*/
function pgjoin($name) {
if($this -> left[$name]) {
unset($this -> left[$name]);
}
if(!$this -> pgroup[$name]) {
$this -> pgroup[$name] = "lft";
$this -> teams ceil(count($this -> pgroup)/6);
}
}



/*
This gets called if someone leaves the privgroup
*/
function pgleave($name) {
if ($this -> pgroup[$name] == "lft") {
unset($this -> pgroup[$name]);

else {
if($this -> teammode == stay) {
$this -> left[$name] = true;

else {
foreach($this -> team[$this -> pgroup[$name]] as $spot=>$spot2) {
if($this -> team[$this -> pgroup[$name]][$spot] == $name) {
$this -> team[$this -> pgroup[$name]][$spot] = gone;
unset($this -> pgroup[$name]);
}
}
}
}
}
}
?>

Title: Custom modules
Post by: craized on April 23, 2005, 05:33:17 am
Great work! I've made a tweak, I removed the 50 team limit, a preference I spose, removed an extraneous space, and added a player count to the unteamed section.
http://www.craized.net/junk/bebot/highlight.php?Teams
I'm tired of rezipping everything, so get my code here if you want.
Title: Custom modules
Post by: Lal on April 23, 2005, 09:15:45 am
wow nice work :)
Title: Custom modules
Post by: Zacix on April 26, 2005, 09:38:15 am
I've mailed craized a new update for the teamsmodule. It should now show level and profession on players in the teams administration screen. Very nice if you don't know all the players when you are making teams. Lets hope craized will post it anytime soon :P
Title: Custom modules
Post by: craized on April 26, 2005, 08:48:59 pm
http://www.craized.net/junk/bebot/highlight.php?Teams
Updated. Great job once again Zacix, great feature for admins.
Title: Custom modules
Post by: craized on April 27, 2005, 06:16:37 am
http://www.craized.net/junk/bebot/highlight.php?Playfield
Playfield module updated, unfortunitely due to the way FC is timing the playfield, every time there is down time for the servers, the PF timer gets tweaked. I'm trying to work in a manual fix at the moment, however it is incomplete. Also,
http://www.craized.net/junk/bebot/highlight.php?Timer
Added multiple timer functionality.
!timer <time> <name>
!timer <name>
!timer clear <name>
this will create, list, and clear a named timer, but I have left in the original !timer <time>, !timer, and !timer clear functions for a main timer.
This module is pretty much done, I'm sure the more dedicated users on this forum will be glad to tell me all the things I did wrong, expect updates and enjoy!


EDIT: !timers in private group chat and tells will now return a clickable blob showing all active timers and their remaining times.
Title: Custom modules
Post by: craized on April 27, 2005, 08:10:06 am
Factioned invites.
http://www.craized.net/junk/bebot/highlight.php?PrivGroup

I've modded this file to check faction before allowing invites.
!faction
Displays the current faction(s) allowed to join bot.
!faction <Clan|Omni|Neutral|All>
Sets which faction(s) are allowed to join the bot.

NOTE: This only affects people inviting themselves through tells, if someone already in the group does !invite <player> it will act normally. Also, this may slow down your bot because it has to do a player lookup on each character it doesn't have already in its database before each invite.
Title: Custom modules
Post by: craized on April 28, 2005, 08:16:00 am
ANNOUNCEMENT:
I'm going to create a new thread for each module because this is getting too hectic. I've created a cute little script, so the links showing the contents of my modules now has a link to a zipped file which is created on the fly, gauranteeing completely up to date content.

Enjoy!
Title: Custom modules
Post by: craized on May 01, 2005, 06:23:49 am
One of my orgmates wanted a timer which counted up, so I threw something together. It's very simple and felt it didn't deserve it's own thread but thought perhaps it would come in handy to someone.

http://www.craized.net/junk/bebot/highlight.php?Stopwatch
Title: Custom modules
Post by: Lal on May 01, 2005, 01:52:44 pm
GJ :) it deserves its own tread :P
SimplePortal 2.3.7 © 2008-2024, SimplePortal