#!/bin/env python import botlib from time import sleep NAME = "clairen" # used for focus simulation # i is just the iterator in the current download, k is the length # k - i - 1 is how many messages there are after the current message, or its depth # the chances of missing a message, using the direct address, etc, depend on this i = k = depth = 0 last16 = [] ### "AI" ### def log_hi(nick): global last16 last16[-1][0] = 'hi' def direct_address(nick, words, pwords): print(words, pwords) if is_hi(words, pwords): log_hi(nick) elif is_gm(words, pwords): log_gm(nick) else: huh(nick) def gossip(nick, line): pass def chatting(nick, line): pass def handle_msg(nick, words, pwords): global NAME, last16 last16 += [('msg', nick, words, pwords)] if nick == NAME: return # things that can be of the form " clairen" nocomma = ['hi', 'hey', 'o/', 'hello', 'thanks', 'ty', 'tysm'] if botlib.strip_direct_address(NAME, nocomma, words, pwords): direct_address(nick, words, pwords) elif NAME in pwords: # "gossip" is messages mentioning us gossip(nick, words, pwords) else: chatting(nick, words, pwords) def handle_action(line): global last16 last16 += None ### BOOT ### botlib.parse_args() while True: sleep(5) writeln(f"SKIP {botlib.lastmsg}") lines = botlib.readmany() for i, line in enumerate(lines): depth = k - i - 1 botlib.handle_line(line, handle_msg, handle_action)