Skip to content

Instantly share code, notes, and snippets.

@jack126guy
Last active Apr 8, 2016
Embed
What would you like to do?
JackBot (Canternet)-specific files for PCommandBot
/*
Main class for JackBot. Like the default main class, it requires a path to the configuration file to be provided on the command line.
PCommandBot: http://github.com/jack126guy/pcommandbot
Custom responders:
* tk.halfgray.pcommandbot.responders.XkcdResponder: http://github.com/jack126guy/pcb-xkcd
Available under the MIT License (below):
----------
The MIT License (MIT)
Copyright (c) 2015 Jack "Fox" Grayson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
----------
*/
package tk.jackgraysonfox.jackbot;
import tk.halfgray.pcommandbot.PCommandBot;
import tk.halfgray.pcommandbot.responders.XkcdResponder;
public class JackBot {
/**
* @param args Command-line arguments
*/
public static void main(String[] args) {
if(args.length < 1) {
System.out.println("Usage: java -jar PCommandBot.jar [configfile]");
System.exit(1);
}
java.io.File configfile = new java.io.File(args[0]);
java.io.FileReader configreader = null;
try {
configreader = new java.io.FileReader(configfile);
} catch(Exception e) {
System.out.println("Could not read configuration file: "+e.getLocalizedMessage());
System.exit(1);
}
PCommandBot bot = new PCommandBot();
try {
bot.loadConfiguration(configreader);
} catch(java.io.IOException e) {
System.out.println("Could not load configuration file: "+e.getLocalizedMessage());
System.exit(1);
} catch(IllegalArgumentException e) {
System.out.println("Could not parse the configuration: "+e.getLocalizedMessage());
System.exit(1);
}
bot.getResponders().put("xkcd", new XkcdResponder());
try {
bot.start();
} catch(Exception e) {
System.out.println("Could not start the bot: "+e.getMessage());
}
}
}
{
"server": "irc.canternet.org",
"port": 6667,
"nicks": ["JackBot"],
"username": "JackBot",
"nickserv_password": "Yes, this bot is identified with NickServ. Pretty sure this isn't necessary. (Yes, I know I accidentally revealed the password earlier; it's been changed.)",
"channels": ["#test", "#techponies", "#EquestrianMusicians"],
"command_prefix": "!",
"argument_terminator": ";;",
"core_command": "p",
"admin_password": "Oh, come on, don't tell me you need this. Just kick/ban it if it's causing problems; it won't come back.",
"commands": {
"help": "This is JackBot. Ask JackG or e-mail <jackgraysonfox@gmail.com> if you seriously want to know how this bot works.",
"h": ["help"],
"ping": "pong",
"foo": "bar",
"baz": "qux",
"cadenza": "Princess Mi Amore Cadenza is the full name of the Crystal Princess and Twilight's former foalsitter. I use this in order to avoid the bit of controversy surrounding \"Cadance\" and \"Cadence\". (Technically \"Cadance\" is the correct spelling, but \"Cadence\" did appear on early materials from Hasbro.)"
},
"default_private": "Hello, I'm a bot. Unless you have a command for me, this is my only response. Say !help for any questions.",
"mentioned_response": "Did someone say something?",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment