TechBot
No admins online? Too busy helping others? Tired of replying to "can i be op"? This chatbot can respond to simple questions like "can i be admin"(which I bet you'll make it say "no") or respond to greetings like "hello"!
Configuring your chatbot
The config is self-explanatory.
#TechBot configuration generated by TechBot version 1.1 Name: TechBot Prefix: [ Suffix: ] #Possible colors: aqua, black, blue, darkaqua, darkblue, darkgray, darkgreen, darkpurple, darkred, gold, gray, green, lightpurple, red, white, yellow NameColor: BLUE ChatColor: GREEN #Choose 2 settings: #broadcast - broadcasts chat to whole server(makes chat seem more real) #pm - message only displays to player(makes it seem like the player is talking to him/her self) ChatMode: broadcast #Choose 2 settings: #read - reads phraselist every chat #load - loads phraselist when the plugin is enabled PhraseListLoading: read
Adding phrases
Warning: Don't add too many phrases or your server WILL lag when someone chats (It will lag less if PhraseListLoading is set to load).
This may be a bit harder. The default phrases.txt looks like this:
#Phrase list for TechBot #Phrases follow this format: #phrasetobedetected:response #do NOT leave any spaces near the colon
A phrase would look like: "i'm new to the server:Welcome to the server!"
If a chat line contains a phrase, the chatbot responds. This means that it would recognize "hello server!" when the phrase is "hello:Welcome!".
The left side of the colon is the phrase that the chatbox will recognize. The right side is the response. Simple?
Download
http://dl.dropbox.com/u/40385683/TechBot.jar
Like TechBot? Donations would always be nice!
Hey this still works, and Id like to see it reimplitated if possible. For some reason, its responds, AS I chat.
@breezeyboy
That's Ample Chat Bot, it misses some features that this plugin has but has a command based response system.
@breezeyboy
Yes, but this is a chatbot and will stay a chatbot.
@Technius
damm would it be possble tho??
@breezeyboy
Nope. This is a chatbot.
Hi errm i was wonding if it would be possable to mute them when they say somehting like op me it will muted them for like 5 mins and they say it again and it will mute them for 10 mins ect...
@SniperFodder
Bam! I think I found exactly what would be useful in this situation:
http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
Fixed Thread Pool! It allows you to add a set number of threads, and then add tasks to an internal que that get sent off to the various threads. When there are no more threads to be used (All the threads are currently working) items get held back until a thread finishes. This could potentially speed up the plugin without overworking the EventDispatchThread (the main server thread).
Check it out: http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool%28int%29
I think ↑ Is perfect for your plugin. You are handling lots and lots of chat messages. Your bottleneck will then be actual server performance instead of the EDT blocking until your search finishes.
@Technius
Hrm.... So for each message sent, you need to run String.indexOf() for each possible matching phrase? If there are a bunch of short little phrases that you are searching, I do suppose indexOf would be faster. Well, some more testing would have to be done. i.e. load all the phrases, and then compile regex's from each phrase, and use the compiled regexs to see if they work better than indexOf().
http://ayende.com/blog/2930/regex-vs-string-indexof
I read through the comments on that and it's up in the air.
There is also a comment that references using StringComparison.OrdinalIgnoreCase with indexOf() to speed it up. That might be useful unless your users are using international characters in their files.
http://stackoverflow.com/questions/2749662/string-comparison-invariantcultureignorecase-vs-ordinalignorecase
It also wouldn't hurt synchronization wise to throw some of the operations in another thread, like the searching. You would recieve the chat event in the main thread, and then dispatch the search + the player to send the message to, to another thread. That other thread executes the searches and sends the message if a match is found. If you did it right, you wouldn't even need to keep creating threads either.
@SniperFodder
No, I'm using String.indexOf
I don't want to run it in another thread, because of synchronization issues.
Are you using Regex to search for matches? Also, you could run most of the processing in another thread. That could help with performance.
Is it possible to add the new &.. colors into the prefix and suffix, and make it possible to talk like a player?
Example: &f<&4Operator&f> &4TechBot&f: "Text"
@rebel24
Maybe about 50-100, depending on the performance of your server.
Warning: Don't add too many phrases or your server WILL lag when someone chats (It will lag less if PhraseListLoading is set to load).
How many phrases would you recommend this could handle before it lags?
@Technius
my config is
@Gaurav1234
Can you post your config as well?
Edit: So if your phrase is "can be op", and the chat says "can i be op", it won't detect it. You need to put "can i be op" or "i want op" or "i want to be op" etc. It doesn't detect individual words.
my config:
Erm, i reloaded the server, and it doesn't respond. No errors in console.
@RedPoptarts
I want exactly what they just say specially the permission nodes. Really awesome plugin, looking forward to it.
I'm more concerned about how many this person thinks is too many before it will cause the server to lag horribly.
@Gaurav1234
@tincopper2
Will do.
@RedPoptarts
Multiple possible detection can be possible. I'll add a bot reply permission. A newline/carriage return character is possible. I'll do group specific responses. Color code will be done. Regex support will come in the format of <name> and <message>.
this plugin has potential... just needs to be updated