Пример #1
0
 def reload_ai(self):
     rebuild(sys.modules['nikkyai'])
     for n in self.nikkies:
         state = self.nikkies[n].get_state()
         self.nikkies[n] = nikkyai.NikkyAI(id=n)
         self.nikkies[n].set_state(state)
Пример #2
0
 def __getitem__(self, k):
     if k not in self:
         self[k] = nikkyai.NikkyAI(id=k, context_lines=CONTEXT_LINES)
     return dict.__getitem__(self, k)
Пример #3
0
personalities = personalitiesrc.personalities

if len(argv) != 3:
    usage_exit()
nick1, nick2 = argv[1], argv[2]
if nick1 != 'nikky' and nick1 not in personalities:
    usage_exit()
elif nick2 != 'nikky' and nick2 not in personalities:
    usage_exit()

if nick1 == nick2:
    tag1, tag2 = '1', '2'
else:
    tag1 = tag2 = None

bot1 = nikkyai.NikkyAI(recurse_limit=10, debug=False, max_lf_l=10, max_lf_r=10,
                       personality=nick1, id='*botchat*', search_time=.1)
bot1.clear_last_replies()
bot2 = nikkyai.NikkyAI(recurse_limit=10, debug=False, max_lf_l=10, max_lf_r=10,
                       personality=nick2, id='*botchat*', search_time=.1)
# No need to also clear bot2's last replies list because it runs off of the same
# ID and therefore shares the list with bot1

tw = textwrap.TextWrapper(subsequent_indent=' '*20, expand_tabs=True, width=80)

def get_response(bot, nick, target_nick, msg):
    msg = '<{}> {}'.format(target_nick, msg)
    reply = bot.reply(msg)
    return reply

def format_response(nick, msg, tag=None):
    msg = msg.split('\n')