.pj: activates autojoin; .pl deactivates autojoin
This commit is contained in:
parent
999c2960fd
commit
20c07af542
@ -1,7 +1,9 @@
|
||||
{
|
||||
"bot": {
|
||||
"autojoin": true,
|
||||
"debug": true
|
||||
"autojoin": false,
|
||||
"debug": false,
|
||||
"pokerbot": "hirc",
|
||||
"channel": "#poker"
|
||||
},
|
||||
"clients": [{
|
||||
"type": "irc",
|
||||
|
@ -26,10 +26,9 @@ bot.on("notice", msg => {
|
||||
});
|
||||
|
||||
bot.on("message", async e => {
|
||||
if(e.channel !== '#poker') {
|
||||
if(e.channel !== cfg.get('channel'))
|
||||
return;
|
||||
}
|
||||
if(e.message === '.schmirc help') {
|
||||
if(e.message === `.${e.self.me.nickname} help`) {
|
||||
await e.write(`PRIVMSG ${e.user.nick} I always say hirc schmirc, available commands are:`);
|
||||
const commands = [
|
||||
' .pj -- poker join',
|
||||
@ -51,22 +50,24 @@ bot.on("message", async e => {
|
||||
if(e.message.match(new RegExp(`^${e.self.me.nickname}: Your bank account`))) {
|
||||
env.bank = +e.message.match(/is: (\d+) \(/)[1];
|
||||
}
|
||||
if(e.message === ".deb") {
|
||||
if(e.message === ".debug") {
|
||||
const tmp = await cfg.set('debug', !cfg.get('debug'));
|
||||
return e.reply(`${!tmp} -> ${tmp}`);
|
||||
return e.reply(`debug mode ${tmp ? '[color=green]enabled[/color]' : '[color=red]disabled[/color]'}`);
|
||||
}
|
||||
if(e.message === ".aj") {
|
||||
if(e.message === ".aj" || e.message === ".autojoin") {
|
||||
const tmp = await cfg.set('autojoin', !cfg.get('autojoin'));
|
||||
return e.reply(`${!tmp} -> ${tmp}`);
|
||||
return e.reply(`autojoin ${tmp ? '[color=green]enabled[/color]' : '[color=red]disabled[/color]'}`);
|
||||
}
|
||||
if(e.message === ".pj" || (e.message === "pj" && cfg.get('autojoin')) && !env.hand && !env.joined) {
|
||||
env.joined = true;
|
||||
await cfg.set('autojoin', true);
|
||||
//return e.reply("pj");
|
||||
return e.reply("bb\npj");
|
||||
return e.reply(["bb", "pj"]);
|
||||
|
||||
}
|
||||
if(e.message === ".pl" && !env.hand) {
|
||||
env.joined = false;
|
||||
await cfg.set('autojoin', false);
|
||||
return e.reply("pl");
|
||||
}
|
||||
if(e.message === ".bb" && !env.hand)
|
||||
@ -80,30 +81,39 @@ bot.on("message", async e => {
|
||||
if(e.message === ".d" && !env.hand)
|
||||
return e.reply("d");
|
||||
|
||||
if(e.user.nick !== 'hirc' || !env.hand)
|
||||
if(e.user.nick !== cfg.get('pokerbot') || !env.hand)
|
||||
return;
|
||||
|
||||
// tracker
|
||||
if(e.message.includes('raises the pot')) {
|
||||
env.callamount = +e.message.match(/raises the pot by (\d+)/)[1];
|
||||
env.pot += env.callamount;
|
||||
if(e.message.includes(e.self.me.nickname))
|
||||
if(e.message.includes(e.self.me.nickname)) {
|
||||
env.bank -= env.callamount;
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`bank: ${env.bank}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.message.includes('calls')) {
|
||||
env.callamount = +e.message.match(/calls (\d+)\./)[1];
|
||||
env.pot += env.callamount;
|
||||
if(e.message.includes(e.self.me.nickname))
|
||||
if(e.message.includes(e.self.me.nickname)) {
|
||||
env.bank -= env.callamount;
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`bank: ${env.bank}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.message.endsWith('blind).')) { // blinds
|
||||
env.callamount = +e.message.match(/pays (\d+) \(/)[1];
|
||||
env.pot += env.callamount;
|
||||
env.gamestate = 'preflop';
|
||||
if(e.message.includes(e.self.me.nickname))
|
||||
if(e.message.includes(e.self.me.nickname)) {
|
||||
env.bank -= env.callamount;
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`bank: ${env.bank}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -119,7 +129,7 @@ bot.on("message", async e => {
|
||||
env.callamount = +e.message.match(/\((\d+) to call\)/)[1];
|
||||
|
||||
if(env.winchance < 6500) {
|
||||
if(helper.rand(5) === 1 && env.callamount < 80) { // bad hand, call anyway
|
||||
if(helper.rand(5) === 1 && env.callamount < (helper.rand(6,10) * 10)) { // bad hand, call anyway
|
||||
action = 'c';
|
||||
}
|
||||
else { // bad hand, fold
|
||||
@ -165,8 +175,12 @@ bot.on("message", async e => {
|
||||
// gamestate & board changes
|
||||
if(e.message.match(/^(Flop|Turn|River)/)) {
|
||||
env.board = helper.parseCards(e.message);
|
||||
const oldstate = env.gamestate;
|
||||
env.gamestate = e.message.match(/(\w+): /)[1].toLowerCase();
|
||||
|
||||
//if(cfg.get('debug'))
|
||||
// e.reply(`${oldstate} -> ${env.gamestate}`);
|
||||
|
||||
const rank = handranker.evalHand([...env.board, ...env.hand]);
|
||||
env.winchance = rank.value;
|
||||
}
|
||||
@ -181,6 +195,9 @@ bot.on("message", async e => {
|
||||
else {
|
||||
env.bank += +e.message.match(/pot(: | of size )(\d+)/)[2];
|
||||
}
|
||||
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`bank: ${env.bank}`);
|
||||
}
|
||||
|
||||
env.gamestate = 'preflop';
|
||||
|
Loading…
Reference in New Issue
Block a user