BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: jjones666 on September 10, 2006, 02:04:37 am
-
based on the standard !blacklist plugin (coded by Foxferal).
improved over original (imo):
- removed code to check if user exists via .xml download and replaced with aoc -> get_uid (burn in hell crappy FC servers).
- if blacklist is empty, it will tell you that with no blob.
- shows blacklist blob when adding and deleting people (if applicable).
- make it impossible to add duplicate entries.
- output also shows !whois clicky for each name (combined with !postit feature, this is very useful).
- changed rem to del, in line with most other plugins.
- colour scheme matches most other plugins.
- updated helpfiles.
http://www.jjones.co.uk/files/blacklist.php
http://www.jjones.co.uk/files/blacklist.txt
-jj-
-
this is perfect only thing i'd like to do is add a reason for the ban too :)
-
I was fooling around with another copy, and figured I might as well post it. Found it to be pretty useful.
Could mod mine to implement the few extra changes from Jack's.
PS: This one includes reasons, but not modified from Jack's (modded from the original)
-
Love both of these, so i am trying to combine the two. Hoping someone here can give me a hand.
Using jjones as the base, and just adding the "added by" and "reason" from Naturalistic.
Everything is set up and converted correctly for the most part. I'm to a point where if i do !blacklist add player1 is properly entered into the db. !blacklist shows player1 [whois] added by Dracutza Reason:
if i type !blacklist add player1 test, where test would be the reason, I get Player player1 test does not exist.
however... i can edit the db directly, entering a reason, and the reason displays as expected.
Unfortunately, the Sets new name in blacklist section (roughly starting on line 95) in both mods is completely different. Copying the INSERT INTO line from Naturalistics works fine, except for the reason value. It's obviously related to how each reads the add command and how the name to be blacklisted ($msg???) is created, but i know zero php, and several things I tried have had no positive effect.
Can maybe one of you tell me what i need to be looking at to get this to accept the reason?
-
Issue with mine was the ' need to change to HTML before inserting into the DB.
Forgot to add that :P
-
- added "blacklisted by" record.
- added (optional) "reason" - if you omit a reason, it will default to "see player notes" - we use !postit feature to record information usually in org.
- works in tell now also.
- alts lookup clicky added to !blacklist output.
- updated helpfiles.
http://www.jjones.co.uk/files/blacklist.php
http://www.jjones.co.uk/files/blacklist.txt
-
Oops, had some DynDNS problems earlier - resolved now.
-jj-
-
thank you for this. I'll have to take a look at it later tonight. I did manage to edit yours to the point where it will record the submitter and a reason. It works well up to the point when someone does not include a reason. We require a reason so the enduser can determine the value of the blacklist entry. We've had members blacklist people because "So and So didn't tip for a wrangle." Requiring a reason at least allows other to determine the value of the blacklist entry. Anyway, if a reason is not entered, the bot does nothing. So now I am trying to figure out how to make the bot reply back that a reason is needed.
Thanks again.
-
Hmm, my update isn't restrictive over the reason, simply because I find the !postit option better as this is more accessable from !whois. If you want it restrictive, I can do this later and post the code I suppose...?
-jj-
-
maybe i should clarify that by "editing yours", i was refering to the one you had posted on 9-9. I have not yet tried the one posted over this weekend.
If you are so compelled to resolve my little problem, I've attached my version of blacklist. What would probably take someone with experience a few minutes will take me a few hours of trial and error, but I'm not afraid of getting this done on my own. Even if i should be afraid of Wolfbiter flaming me for unethical coding (http://bebot.link/index.php/topic,425.msg2712.html#msg2712) :D
In any event, that you all for the help already, and really making a great bot.
-
Wolfbiter rocks, at least Bebot wise.
Natu, well, apart from being superadmin-of-some-bot-or-other, I'm still waiting for his updated depot module and he is persistant troller on Zodsnet forum :-)
(And, I'll have a look at the code later for you).
-jj-
-
maybe i should clarify that by "editing yours", i was refering to the one you had posted on 9-9. I have not yet tried the one posted over this weekend.
If you are so compelled to resolve my little problem, I've attached my version of blacklist. What would probably take someone with experience a few minutes will take me a few hours of trial and error, but I'm not afraid of getting this done on my own. Even if i should be afraid of Wolfbiter flaming me for unethical coding (http://bebot.link/index.php/topic,425.msg2712.html#msg2712) :D
In any event, that you all for the help already, and really making a great bot.
Ok try replacing the code to handle messages in the module I posted yesterday with the below. Should be fine for what you need I hope.
-jj-
/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "blacklist add ([^\s]+) (.+)$/i", $msg, $info))
$this -> bot -> send_pgroup($this -> set_blacklist($name, $info[1], $info[2]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist add (.+)$/i", $msg, $info))
{
$msg = "You must enter a reason!";
$this -> bot -> send_pgroup($msg);
}
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist del (.+)$/i", $msg, $info))
$this -> bot -> send_pgroup($this -> del_blacklist($name, $info[1]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist{0,1}$/i", $msg))
$this -> bot -> send_pgroup($this -> get_blacklist());
else
$this -> bot -> send_pgroup($this -> get_blacklist());
}
/*
This gets called on a msg in the guildchat with the command
*/
function tell($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "blacklist add ([^\s]+) (.+)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> set_blacklist($name, $info[1], $info[2]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist add (.+)$/i", $msg, $info))
{
$msg = "You must enter a reason!";
$this -> bot -> send_tell($name, $msg);
}
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist del (.+)$/i", $msg, $info))
$this -> bot -> send_tell($name, $this -> del_blacklist($name, $info[1]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist{0,1}$/i", $msg))
$this -> bot -> send_tell($name, $this -> get_blacklist());
else
$this -> bot -> send_tell($name, $this -> get_blacklist());
}
/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "blacklist add ([^\s]+) (.+)$/i", $msg, $info))
$this -> bot -> send_gc($this -> set_blacklist($name, $info[1], $info[2]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist add (.+)$/i", $msg, $info))
{
$msg = "You must enter a reason!";
$this -> bot -> send_gc($msg);
}
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist del (.+)$/i", $msg, $info))
$this -> bot -> send_gc($this -> del_blacklist($name, $info[1]));
else if (preg_match("/^" . $this -> bot -> commpre . "blacklist{0,1}$/i", $msg))
$this -> bot -> send_gc($this -> get_blacklist());
else
$this -> bot ->send_gc($this -> get_blacklist());
}
-
Just a suggestion JJ.
You might want to look at how we handle commands in newer modules in SVN. Imho it's a cleaner way, although i still need to clean up more.
See http://svn.shadow-realm.org/index.py/BeBot/trunk/modules/Roster.php?revision=247&view=markup as an example.
Basically, common handler for all messages (avoids typos and code repetition), common handler is told what type of command it is so it can handle tells differenly from pgroup etc if wanted. But most importantly, the way commands are parsed.
First we split the incoming string into variables ($vars) using explode(), then we strip the command prefix, assign the actual command passed to $command for easy parsing and reference, and then use switch() to handle what we today use regexp for.
What i still need to do with this is more as much code as possible out of the main command handler, for example, the error checking done there now on each command should be done inside send_out instead. But non the less, it should serve as a decent example of what i think is a better way to do command handling.
-
Khalem,
Would that type of command processing work in Bebot 0.2.x?
I agree, it does look a lot simpler...
-jj-
-
I would have to disagree about adding it... 0.2.x is going out of date ;)
-
This way of doing it works just fine in 0.2.x as well, you just won't have the luxury of the send_output function.
But i still heavily recommend at least using the unified command handler approach, ie having tell, pgmsg, tell2 and gc handed over to a handler function along with a flag stating it's origin.
The method displayed in the example when it comes to parsing and code location is not ideal, and is partly caused by being in between transition from the old system and the planned system. The advantage of it is that the way it's done right now is fully backwards compatible, and at the same time, will require very little work to update to the final system which will arrive hopefully in 0.5.x
-
This last version is really nice. Question about the alts feature though. Are the alts/whois/blacklist feautures all supposed to tie into one another?
As it is now, we blacklist Player1234. he has an alt, Player5678 which has been added to our alts list.
!whois Player1234 shows that nice "Warning! Blacklisted!::" tag. "alts" link added and upon clicking shows Player5678
!whois Player5678 does not however show the blacklist warning. Is it supposed to?
-
If you use my modified !whois module it will...
http://bebot.link/index.php/topic,204.30.html (pay attention of other required modules).
or
http://bebot.link/index.php/topic,314.0.html (just requires the Whois cache).
ie:
Uprnet: Jahbless "Ninjans" Atmosphere is a level 213 (AT 9 - Mediocre) Male Opifex Martial Artist, Clan.:: Warning! Main Blacklisted! View Niceas's Alts
-
ok I can't get jj's to work at all, bot just keeps telling me to ask for help. Natural's keeps telling me There isn't any person named XXXXX registered on Rubi-Ka!.
So what am I missing?
-
Make sure you don't have any extra spaces, try to capitalize the first letter in the names.
And are you using the right commands?
-
I got it to add on yours.. but now I can't get it to delete lol.. keep telling me "You must use the proper command."
Using !blacklist del XXXXX
-
Try !blacklist rem <name>
-
Also useful, place this in the Blacklist.php to global check if a user is banned.
How to use: (in another module, that you wish to see if the person is banned)
if ( !$this -> bot -> Blacklist -> is_banned($name) )
{
Do stuff if not banned
}
else
Do other stuff if banned
function is_banned($name)
{
$result = $this->bot->db->select("SELECT name FROM blacklist where name='" . $name . "'");
if (!empty($result))
return $name;
else
return false;
}
-
Thx a ton Naturalistc all is good :D
-
Reason with ' in it seems to break the command. It will say the user has been listed but doesn't actually add the user to the database.
-
Put an addslashes function around the string you are handing to the database. Otherwise, some characters will be misinterpreted, and in theory might make it possible to inject SQL.
Can't test it right now, but something like
$this -> bot -> db -> query("INSERT INTO blacklist (whoset, name, reason) VALUES ('" . $name . "', '" . $msg . "', '" . addslashes($reason) . "')");
might work. Actually, I don't think it would hurt at all to put an addslashes function around every string that gets inserted into the database.