tetrapus / Karkat

Multithreaded python IRC socket bot.
16 stars 5 forks source link

CaH not functional? #81

Open darkshade9 opened 9 years ago

darkshade9 commented 9 years ago

I know the bot is in a state of reconditioning and upgrading, I just wanted to see if the CaH portion was one of the parts that is expected not to work. I can get it to work for the most part until it tries to insert a score, then it just hangs forever.

Error in function plugins.games.cah.CAHBot.trigger(<StatefulBot(globalgamers, started 140479874713344)>, ':cahtest!webirc@x.x.x.x PRIVMSG #cah.test :!pick 2') Traceback (most recent call last): File "/home/games/karkat/bot/threads.py", line 356, in run funct(_args) File "/home/games/karkat/bot/threads.py", line 507, in call return self.funct(_args) File "/home/games/karkat/plugins/games/cah.py", line 618, in trigger game.logwinner([int(x[4])-1], self.expansiondir) File "/home/games/karkat/plugins/games/cah.py", line 411, in logwinner logdata.execute("INSERT INTO white VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", (timestamp, player.nick, self.channel, self.round, self.czar.nick, self.question.text, ", ".join(player.responses), 0, origrank)) TypeError: sequence item 0: expected str instance, AnswerCard found

tetrapus commented 9 years ago

Sorry, I accidentally pushed a broken version of the code a while back and was a bit too lazy to move it to a different branch, the working code is in https://github.com/tetrapus/Karkat/blob/37c2e0cfd85461ae581df2215d7a420df7b2a7f1/plugins/games/cah.py

darkshade9 commented 9 years ago

Does this work with the newest Karkat or do I need to have the same commit that the above came from? I'm getting a ton of errors:

On player join:

Error in function plugins.games.cah.CAHBot.trigger(<StatefulBot(globalgamers, started 140000509318912)>, ':testuser!webirc@xxxxxxx PRIVMSG #cah.test:!join') Traceback (most recent call last): File "/home/games/karkat/bot/threads.py", line 355, in run funct(_args) File "/home/games/karkat/bot/threads.py", line 506, in call return self.funct(_args) File "/home/games/karkat/plugins/games/cah.py", line 569, in trigger if game.addPlayer(nick): File "/home/games/karkat/plugins/games/cah.py", line 238, in addPlayer self.repopulate(p) File "/home/games/karkat/plugins/games/cah.py", line 284, in repopulate card = re.sub(r"\$([A-Z]+)", lambda x: self.var(x.group(1)), card) File "/usr/lib/python3.4/re.py", line 175, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or buffer

On game start, and it freezes up at this point:

Error in function plugins.games.cah.CAHBot.trigger(<StatefulBot(globalgamers, started 140000509318912)>, ':me!xxxxxx PRIVMSG #cah.test :!start') [0] irc.globalgamers.net ← PRIVMSG Traceback (most recent call last): File "/home/games/karkat/bot/threads.py", line 355, in run funct(_args) File "/home/games/karkat/bot/threads.py", line 506, in call return self.funct(_args) File "/home/games/karkat/plugins/games/cah.py", line 589, in trigger game.start() File "/home/games/karkat/plugins/games/cah.py", line 484, in start self.next() File "/home/games/karkat/plugins/games/cah.py", line 377, in next self.question = re.sub(r"\$([A-Z]+)", lambda x: self.var(x.group(1)), self.question) File "/usr/lib/python3.4/re.py", line 175, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or buffer

tetrapus commented 9 years ago

Sorry, linked to wrong commit https://github.com/tetrapus/Karkat/blob/ddd8452ab02c2c6252276d9719d1a30368d3490b/plugins/games/cah.py

darkshade9 commented 9 years ago

Perfect, thanks!

darkshade9 commented 9 years ago

Seems there's a slight bug I'm running into, it will occur at any time during the game, it stops showing cards to players, and even !hand won't show it. Here's the log:

Error in function plugins.games.cah.CAHBot.trigger(<StatefulBot(globalgamers, started 139736031418112)>, ':philliesfan136!webirc@xxxx PRIVMSG #xxx.cah :!hand') Traceback (most recent call last): File "/home/games/karkat/bot/threads.py", line 354, in run funct(_args) File "/home/games/karkat/bot/threads.py", line 505, in call return self.funct(_args) File "/home/games/karkat/plugins/games/cah.py", line 487, in trigger player.printHand(printer) File "/home/games/karkat/plugins/games/cah.py", line 617, in printHand for i in self.getHand(): File "/home/games/karkat/plugins/games/cah.py", line 623, in getHand lines.append(CAHPREFIX + "%d. %s" % (i+1, card[0].upper() + card[1:])) IndexError: string index out of range