From 9a0915a59d59af94635c479c933b005bd512c1c9 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sat, 15 Nov 2025 16:36:09 -0500 Subject: [PATCH] add a new command --- botlib.py | 4 +-- dee.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/botlib.py b/botlib.py index 5ed96aee4415075255cd275ce3e0a815884bd2b7..a2b0b249c0bc09d9c93c13312257feef02c2ed45 100755 --- a/botlib.py +++ b/botlib.py @@ -22,11 +22,11 @@ def usage(): ### "AI" ### -def split_list(words, pwords): +def split_list(words, pwords, fillers): terms = [] acc = [] for i in range(len(words)): - if len(acc) == 0 and pwords[i] in ('and', 'or'): + if len(acc) == 0 and pwords[i].lower() in fillers: continue if words[i][-1] == ',': acc.append(words[i].rstrip(',')) diff --git a/dee.py b/dee.py index 23f7f5cef6e5ae45b97f07426556c91f8b81239b..e5f6ddf224d09951db49a2ab8493f0c5f8a00765 100755 --- a/dee.py +++ b/dee.py @@ -46,7 +46,7 @@ def handle_msg(nick, line, words, pwords): if cmd == 'help': help(nick) - elif cmd not in ('roll', 'pick', 'shuf', 'shuffle'): + elif cmd not in ('roll', 'pick', 'shuf', 'shuffle', 'do', 'don\'t', 'should', 'are'): send(f'{nick}, I don\'t know how to do that! My help is at {MAN}') elif len(pwords) < 1: send(f'{nick}, {cmd} what?') @@ -56,6 +56,28 @@ def handle_msg(nick, line, words, pwords): pick(nick, words, pwords) elif cmd in ('shuf', 'shuffle'): shuf(nick, words, pwords) + elif cmd == 'do': + if pwords[0].lower() == 'i': + do_i(nick, words[1:], pwords[1:]) + elif pwords[:2] == ['you', 'think']: + dyt(nick) + else: + send(f'{nick}, do what?') + elif cmd == 'should': + if pwords[0].lower() == 'i': + do_i(nick, words[1:], pwords[1:]) + else: + dyt(nick) + elif cmd == 'don\'t': + if pwords[0].lower() == 'i': + dyt(nick) + elif pwords[:2] == ['you', 'think']: + dyt(nick) + else: + send(f'{nick}, don\'t what?') + elif cmd == 'are': + dyt(nick) + def handle_action(line, words, pwords): @@ -64,16 +86,61 @@ def handle_action(line, words, pwords): ### CHOICES, CHOICES ### -def pick(nick, words, pwords): - terms = botlib.split_list(words, pwords) - picked = choice(terms) - send(f'{nick}, how about {" ".join(picked)}?') +def pick(nick, words, pwords, ignore=['or']): + formats = [ + 'my sources tell me {} is the best option.', + 'how about {}?', + 'I\'ve got a good feeling about {}.', + 'if I *had* to pick, I\'d say {}.', + 'signs point to {}.', + '{}!', + 'try {}... if you dare!', + 'a terrible fate will befall you! ...unless you pick {}!', + 'after extensive deliberation, I think {} is the only option', + 'nothing ventured, nothing gained! try {}.', + ] + + terms = botlib.split_list(words, pwords, ignore) + picked = " ".join(choice(terms)).rstrip('?') + reply = choice(formats).format(picked) + send(f'{nick}, {reply}') def shuf(nick, words, pwords): - terms = botlib.split_list(words, pwords) + terms = botlib.split_list(words, pwords, ['and']) shuffle(terms) send(f'{nick}: {", ".join(map(" ".join, terms))}') +def do_i(nick, words, pwords): + if 'or' not in pwords: + dyt(nick) + else: + for word in words: + if word.endswith(','): + pick(nick, words, pwords, ['or', 'do', 'should', 'i']) + break + else: + dyt(nick) + +def dyt(nick): + replies = [ + 'yes', + 'yeah!', + 'absolutely!', + 'sure', + 'signs point to yes', + 'totally!', + 'no', + 'nah', + 'signs point to no', + 'never in a million years!', + 'maybe', + 'dunno', + 'not sure', + 'ask again later' + ] + + send(f'{nick}, {choice(replies)}') + ### DICE ### @@ -170,7 +237,7 @@ def dice(nick, words, pwords): result = nick - terms = botlib.split_list(words, pwords) + terms = botlib.split_list(words, pwords, ['and']) print(f'{terms=}') for term in terms: try: