From 4103f9fbdf4c5770987ca51980dea167f24d0b43 Mon Sep 17 00:00:00 2001 From: xfnw Date: Sun, 12 Jul 2020 12:21:53 +0000 Subject: [PATCH] conversation flow --- bot.py | 2 +- modules/__pycache__/admin.cpython-36.pyc | Bin 4121 -> 5049 bytes modules/__pycache__/channels.cpython-36.pyc | Bin 242 -> 237 bytes modules/__pycache__/nlp.cpython-36.pyc | Bin 2884 -> 3275 bytes modules/admin.py | 70 ++++++++++++++------ modules/nlp.py | 31 +++++++-- 6 files changed, 74 insertions(+), 29 deletions(-) diff --git a/bot.py b/bot.py index 9a07f99..109b41b 100755 --- a/bot.py +++ b/bot.py @@ -94,6 +94,6 @@ class Oven(pydle.Client): if __name__ == "__main__": client = Oven('kim', realname='owens bot') client.admins = ['lickthecheese', 'ben', 'coffeeowl', 'gbmor', 'tomasino', 'ubergeek', 'deepend', 'calamitous', 'khuxkm'] - client.prefix = '.' + client.prefix = 'kim: ' client.run('team.tilde.chat', tls=True, tls_verify=False) diff --git a/modules/__pycache__/admin.cpython-36.pyc b/modules/__pycache__/admin.cpython-36.pyc index c4531f521561d4771291bb7715d7ba8d7f12776f..0e1e0971227e2e2ca0257bef7c4684f561f196b1 100644 GIT binary patch literal 5049 zcmbVQ&2Jn@74Pcq`SAE7wv%<@Y(C0?4H=Z!AqfGz#>=un#M168(h8Dz6dE(_ZS}*#_Fni_3`R`zgK=Z zJKOm84;wpwS+J~sS*71J#y`QQzeXc0!2)YL>)AFlu)S@Y-r079Eu1f{ZCALWg1#cE zqK3XI>S79gO*F(b`ns4Av*@S9oVb9#A?C#b`f0H!E~1|im&7~hXT_4ZjDAj5WL3Jd zChKxq&d4b_E9b2^ z;H1Y!_Q*N0PuLbXdTKGWIBmC*%U>MxI0^*sOZ2=G_4|Izzc_B%srzc^$7yvpQhhIO zx~Z#Wu$#J_t{0|N9Sv1SrcPh){nb)+-1PQaYu%_X*A92XgSCCXf6rH)wSFXqfz)fB z==PnQFh9uvQLYHFa?mtgMK`GmHC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b_%F_J7Zna!zU5p5@p1P#*kr5D~oW2m%|nP==o ziP#XWwmekMuDmP;q0o!W{KJey4my@9=5bqkYI=E5h~Fw(HJKk>$N4aWLSlJVXJQEn zv%g@HHzPs$x!hhrJ5hQ;53hZm-x%LU{AlkS6KnC``P-6GUe*PJ#+l&|{~8U>c8X zPplE9#EZ@NkK*~ubpOB7`;!d~nj@N5@GYiUm8q=8mSsUt?oc4~BTW^NlHnUPA}T;E z>}MrvPt=;IEm2FNc0{cR$_FJZbs5H>av&2qQtxr7j?e_|J;jzZf^~%0fJUf+Xa;6S z=rKf(!`ukXBQjuNgccE*aBYN^5G_AKD~PC!R(BIE&CeiXIxRa02W2yDW~Z0kY)~?f zT_1wu&bYiX8ccX!3M%?ZW@}}b*HZP{irU;#`-Qgna*$&4wTR1Jx^$+`l zoEfIQFf~l6bMYTSjtH)i aNn&(G(G^|Oi@KVQ0@^sJLtGu`Q~VcHV|pO~ diff --git a/modules/__pycache__/channels.cpython-36.pyc b/modules/__pycache__/channels.cpython-36.pyc index e35aafe8e0051b7a130aec084aa00a1c24597bce..b03f2d2ef732d99d80537f3cf8878eebdc58ae72 100644 GIT binary patch delta 39 ucmeyw_?D5wn3tF9wJBHpM2<>fHT{hI+*JLFw7hct?95!<%%bFpGa~`@x(z)5 delta 44 zcmaFM_=%Cjn3tE!@6MdKi5!&@+WHy!xvBa&naSBD8L7z`sj0=O`q`Pe6Q@K108>p6 A00000 diff --git a/modules/__pycache__/nlp.cpython-36.pyc b/modules/__pycache__/nlp.cpython-36.pyc index 8f37225d4df3de7b80de212d86b7a917f86695da..9a09023f6d671eef0866f7728c524367ae8966ba 100644 GIT binary patch delta 1568 zcma)6&2Jl35P$Rbdt;|11=mTNhDsDz3NeiXRK=y#h< z|Is6Vd&NKUzlEQUj&8j3ap_zWx37=g(pJ{4#H2J6Ss10OyhE4*h_qG8#3YGLGXGGj zxdBXNH4hzVR2$HiskkPlFg9Z`whop`pvo4;HdRE~PocC*yC?4UZi&Jq-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oAVc&mjkQ2}zlh7o!Jf)z(g>R&=&SiKRzATJ}fT1nP z6BrFZPcT3(JV0M?z`%wuMv?HBi6Af%!P+lV#SRRwyxHk=MAvrLyM=6vb%XBTVs+kP z8#_<;2S9R&CWW*vOmnSeYRAoRX$Usv3c^){ZxN6==b7%$2^|;wsF)vV=1MF3BN!Ff z=Y&qOfCUsEa~sakXy3!jTtrwzs5wR|$E2eFni4Pv7C$4g4m4f8m^>SX(M)ta3jYNu Cd: quit reload commit part join joins eval send'] self.help['admin quit'] = ['admin quit - make the bot disconnect','no'] @@ -96,7 +124,7 @@ async def init(self): self.help['admin joins'] = ['admin joins - join more channels', 'dont reconnect to a bunch of chans when the bots crashing etc'] self.help['admin eval'] = ['admin eval - absolute power corrupts absolutely', 'lmao'] self.help['admin send'] = ['admin send - send a message', 'lmao'] - + self.help['admin schans'] = ['admin schans - save the commands to join',';p;'] diff --git a/modules/nlp.py b/modules/nlp.py index 0eef0b8..d13d0ce 100644 --- a/modules/nlp.py +++ b/modules/nlp.py @@ -21,12 +21,28 @@ async def rec(self, m): noch.insert(dict(word=w)) end.insert(dict(word=pre)) -async def getNoun(self, words): - nouns = [i['word'] for i in self.db['noun'].find()] - out = {} - for i in words: - out[i] = nouns.count(i) - return min(out, key=out.get) +async def getNoun(self, words, c): + if c in self.cstate: + oldnoun = self.cstate[c] + else: + oldnoun = None + nouns = [i['word'] for i in self.db['noun'].find()] + out = {} + for i in words: + out[i] = nouns.count(i) + noun = min(out, key=out.get) + + conversation = self.db['conver'] + if oldnoun != None: + print("adding", [oldnoun,noun]) + conversation.insert_ignore(dict(pre=oldnoun,pro=noun),['id']) + + nextnoun = [i['pro'] for i in conversation.find(pre=noun)] + print("nextnoun:",nextnoun) + if len(nextnoun) > 0: + noun = random.choice(nextnoun) + self.cstate[c] = noun + return noun async def genOut(self, noun): prew = self.db['prew'] @@ -72,7 +88,7 @@ async def go(self, c, n, m): words = m.split(' ') if words[0] == 'admin': return - await self.message(c, ' '.join(await genOut(self, await getNoun(self, words)))) + await self.message(c, ' '.join(await genOut(self, await getNoun(self, words, c)))) async def init(self): @@ -83,3 +99,4 @@ async def init(self): self.enmul = 25 self.raw['nlp'] = filter + self.cstate = {}