Skip to content

Instantly share code, notes, and snippets.

@Efreak
Created November 2, 2015 23:47
Show Gist options
  • Save Efreak/2a5bbdba29264d97e231 to your computer and use it in GitHub Desktop.
Save Efreak/2a5bbdba29264d97e231 to your computer and use it in GitHub Desktop.
// To run this example without first copying it outside of node_modules/steam-chat-bot, use ./ as the require path, e.g.:
// var ChatBot = require("./").ChatBot
var ChatBot = require("steam-chat-bot").ChatBot;
var myBot = new ChatBot("xxx", "xxx", {
//this is required on the first run if you have steamguard enabled, but not after that.
guardCode: 'TFP9X',
//the built-in webserver is enabled by default
disableWebServer: false,
//If you run steam-chat-bot as root, it will eat your babies. DO NOT RUN steam-chat-bot AS ROOT. Use nginx, lighttpd, or apache as a frontend webserver, or use iptables or your router to forward the port. DO NOT RUN AS ROOT!
webServerPort: 8080,
//file that contains which chats to join on connect
autojoinFile: "bot.username.autojoin",
//Color logs in the console? errors are red, etc.
consoleColors: true,
//timestamp logs in console?
consoleTime: true,
//can also be error, debug, none, or other valid winston log levels. Mostly, only Error, Debug, Info get used.
logLevel: "info",
//can also be error or debug - only controls what gets logged to console; above controls the logfile.
consoleLogLevel: "info",
//this does *not* log chatter. If you want to log chatter, use the logTrigger.
logFile: "bot.username.log",
//this is your ssfn file. No, you can't actually use an ssfn file, and we won't help you try.
//Bot tries to find a sentry file automatically. This is only required if you have one with a strange name, otherwise it's automatic.
sentryFile: "bot.username.sentry",
//Why would you *not* want it to autoconnect?
autoconnect: true,
//You probably want to set this to true, though...
autoReconnect: false,
//the path to the favicon that will be used by your webserver
//If you use a reverse proxy for logs, you'll need to make sure this gets passed along too (if you actually want it)
favicon: "htt://yourwebsite.com/favicon.ico",
//log metadata about all http requests?
httpLogMeta: true,
//format expressWinston logs the way it likes?
httpFormat: false,
//that's 5 minutes, if you can't do math. The babysitter checks to make sure we're online if above is true.
babysitTimer: 5*60*1000,
//ignore these people for all triggers that don't explicitly *not* ignore them. (this way you can still log them)
ignores: ['steamid64','steamid64','steamid64']
});
// Set up the triggers to control the bot
myBot.addTriggers([
{ name: 'ModerateTrigger', type: 'ModerateTrigger', options: { }},
{ name: 'BanTrigger', type: 'BanTrigger', options: {} },
{ name: 'JoinChatTrigger', type: 'JoinChatTrigger', options: {} },
{ name: 'AntispamTrigger', type: 'AntispamTrigger', options: {} },
{ name: 'SetNameTrigger', type: 'SetNameTrigger', },
{
name: 'general commands',
type: 'ChatPmTrigger',
options: {
matches: ['!cmds'],
responses: [ "use !rules for rules, !g (search) to google something, !admin for a list of current admins."],
exact: true,
}},
{
name: "sakura",
type: "MessageOnJoinTrigger",
options: {
user: "76561197987785951",
message: "Unbelievable. You, SilentSakura ,must be the pride of GirlGamers here.",
probability: 1
}
},
{
name: "burgie",
type: "MessageOnJoinTrigger",
options: {
user: "76561198049432668",
message: " Well done. Here are the test results: You are a horrible person. I'm serious, that's what it says: (A horrible person.) We weren't even testing for that. Don't let that horrible-person thing discourage you. It's just a data point. If it makes you feel any better, you are my best test subject Burgie."
,
probability: 1
}
},
{
name: "Kurochi",
type: "MessageOnJoinTrigger",
options: {
user: "76561198040894127",
message: " Oh, It's you. It's been a long time."
,
probability: 1
}
},
{
name: "Pinkfire",
type: "MessageOnJoinTrigger",
options: {
user: "76561198093720530",
message: "Pink, This is your fault. I'm going to kill you. And all the cake is gone. You don't even care, do you?"
,
probability: 1
}
},
{
name: "Rebs",
type: "MessageOnJoinTrigger",
options: {
user: "76561198180527389",
message: "Do you think I'm trying to trick you with reverse psychology? I mean, seriously, now."
,
probability: 1
}
},
{
name: "companion cube",
type: "ChatReplyTrigger",
options: {
matches: [":p2cube:"],
responses: ["Please escort your Companion Cube to the Aperture Science Emergency Intelligence Incinerator"],
exact: false,
delay: 1000,
probability: 0.2,
timeout: 10*1000
}
},
{
name: 'rules',
type: 'ChatPmTrigger',
options: {
matches: ['!rules'],
responses: [ "use !general for general rules.\n!bigotry for harrasment/bigotry rules.\n!linking for linking rules. "],
exact: true,
}},
{
name: 'admins',
type: 'ChatPmTrigger',
options: {
matches: ['!admin'],
responses: [ "Burgie the bestest test subject , Pinkfire the pinkinator, Rebs the hugger, Silentsakura the unspeaking. "],
exact: true,
}},
{
name: 'linking rules',
type: 'ChatPmTrigger',
options: {
matches: ['!linking'],
responses: [ "Linking\nLinks of any kind should be brought to the attention of a moderator before posting.\nLinks are subject to all of the rules listed here, and you will be held responsible for the content contained within them.\nNo porn/gore image links.(Instant Ban - Anyone posting will be reported).\nPlease do not advertise external websites, servers, or groups within our forums or public chat without first consulting a group officer/moderator.\nNo linking to or discussing hacks, keygens, or pirated content (This will result in an instant ban without possibility of appeal as it poses a threat to other users). "],
exact: true,
}},
{
name: 'general rules',
type: 'ChatPmTrigger',
options: {
matches: ['!general'],
responses: [ "General\nPlease use English only! We cannot moderate other languages, therefore we must prohibit the use of any language other than English.\nVulgarity, obscenities, profanity, initialisms, or verbal indecency of any kind, even censored or shortened, is strictly prohibited. Failure to abide by this rule will result in a permanent chat ban and a kick from the group.\nIf you block an officer or moderator you will be kicked from the group.\nVoice chat is completely prohibited. If you are using it in our public chat, you will be banned.\nSeeking a boyfriend/girlfriend/'good time' will result in a permanent ban.\nFake profiles will get removed from this group if they are caught.\nNo begging of any kind.\nDo not spoil anything (books, TV shows, movies, etc...) that isn't at least over three years old.\nWhile it is alright to consume alcohol in chat, if it gets out of hand even slightly you will be banned. It makes for a very immature and unruly chat environment.\nDo not spam anything; this includes symbols, letters, emoticons, links, capitalized words, etc... \nNo rude/offensive/disgusting names or profile pictures. You will be banned immediately if this is seen.\nGiving out, asking for, or exchanging phone numbers is off limits.\nRP (roleplay) is prohibited. Offering it or asking for it will result in a permanent ban.\nPlease limit trade requests to one post a day; this is not a trading community. If you are interested in a trade, take the conversation to private messages."],
exact: true,
}},
{ name: 'SteamrepOnJoin',
type: 'SteamrepOnJoinTrigger',
options: {} } ,
{
name: "unnamed enter",
type: "DoormatTrigger",
options: {
delay: 4000,
probability: 0.4,
timeout: 60*1000
},},
{
name: 'linkname',
type: 'LinkNameTrigger',
options: {}
},
{
name: 'Google',
type: 'GoogleTrigger',
options: { command: '!g' }
},
{ name: 'DirectCleverbotReply',
type: 'CleverbotTrigger',
options: { keywords: ['Glados'] } },
{ name: 'RandomCleverbotReply',
type: 'CleverbotTrigger',
options: { probability: 0.005, timeout: 30*60*1000 } },
{
name: 'harassment rules',
type: 'ChatPmTrigger',
options: {
matches: ['!bigotry'],
responses: [ "Harassment & Bigotry\nGeneral racism, sexism, or bigotry will result in a ban.\nFailure to be accepting of the gender, nationality, creed, religion, beliefs, sexuality, etc… of a member will result in a permanent ban for good; no exceptions. \nDo not harass members; this includes personal attacks, jabs, quotes, or even things said in jest.\nThis is an LGBT safe chat/group. Homophobic/Transphobic slang or hatred is strictly prohibited and will result in a permanent ban." ],
exact: true,
}},
]);
myBot.connect();
// Trigger details can be retrieved and reloaded so that external configuration can be supported
//var details = myBot.getTriggerDetails();
//myBot.clearTriggers();
//myBot.addTriggers();
//these are useful for displaying your bot as playing a game, so it shows up in the upper part of the userlist.
//this is a comma-separated array of games that the bot will play automatically on login. 440 is tf2.
//myBot.setGames([440]);
//this will stop all games, start the game listed (the first parameter), then after a delay in ms (the second param), start any games it was already playing. 570 is dota2.
//myBot.setPrimaryGame(570,250);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment