def test_is(self): s = parser.parse(self.magic_token + " ISA #troll http://t.co") self.assertIsInstance(s, statements.IsA) self.assertEqual(s.group, '#troll') s = parser.parse(self.magic_token + " ISA #troll @trollbob") self.assertIsInstance(s, statements.IsA) self.assertEqual(s.group, "#troll") self.assertEqual(s.member, "@trollbob")
async def on_message(message): if message.author == client.user: return content = message.content.split(" ") if len(content) == 1: if content[0] == '!f' or content[0] == '!flip': ast = ddparser.parse(message.author, '1d2') result = ddparser.compute(ast) if result == 1: await message.channel.send(':heads:') else: await message.channel.send(':tails:') if content[0] == '!rps' and type(message.channel) is not DMChannel: if message.channel.guild.id in rpsDict: ast = ddparser.parse(message.author, '1d3') result1 = ddparser.compute(ast) result2 = ddparser.compute(ast) output = rpsDict[message.channel.guild. id] + ' ' + rpsValues[result1] + ' vs ' output += rpsValues[result2] + ' ' + message.author.name await message.channel.send(output) rpsDict.pop(message.channel.guild.id) else: rpsDict[message.channel.guild.id] = message.author.name if len(content) < 2: return output = '' if content[0] == '!r' or content[0] == '!roll': for x in range(1, len(content)): ast = ddparser.parse(message.author, content[x]) result = ddparser.compute(ast) output += content[x] + ':' + str(result) + " " await message.channel.send(output) if len(content) != 7: return if content[0] == '!s' or content[0] == '!stats': result = dddatabase.insert_character(message.author.id, content) if result == 0: await message.channel.send('Stats Saved') else: await message.channel.send('Stats Format Incorrect')
def test_bunchOfStuff(self): statements = [ "ISA #jerk", # i am a jerk "ISA #jerk @fred", # fred is a jerk "ISA #jerk @fred @joe", #joe says fred is a jerk "NOTA #jerk", # i am not a jerk "NOTA #jerk @alice", # alice is not a jerk "NOTA #jerk @alice @bob", #bob says alice is not a jerk "AGREE http://s1.co",# i agree with this docuent, "AGREE http://s1.co @alice", # alice agrees with this document "AGREE http://s1.co @alice @eve", # eve says alice agrees with this document "DISAGREE http://s1.co", # i disagree with this document "DISAGREE http://s1.co @alice", # alice disagrees with this document, "DISAGREE http://s1.co @alice @eve", # eve says alice disagrees with this document "TRUST http://s1.co", # i trust this document "TRUST http://s1.co @fred", # fred trusts this document "TRUST http://s1.co @fred @alice", # alice says fred trusts this document "DISTRUST http://s1.co", # i distrust this document "DISTRUST http://s1.co @alice", # alice distrusts this document "DISTRUST http://s1.co @alce @bob", # bob says alice distrusts this document "SAME http://s1.co http://s2.co", # these are the same identities "SAME http://s1.co http://s2.co @fred", # fred says these are the same "HURT http://s1.co", # this content here hurts. i dissaprove of this. i don't like this, etc "HURT http://s1.co @Bob", # bob hurt me, this content explains it "HURT http://s1.co @bob @alice", # alice says bob hurt here here "FORGIVE dewdrop://link-to-hurt", # this content is forgiven - it's a way of saying you are now ok with this thing that has happend # the link should be a previous hurt statementx "FORGIVE dewdrop://link-to-hurt @alice", # i forgive alice for this wrong "FORGIVE dewdrop://link-to-hurt @alice @bob", # bob has forgiven alice for this wrong "THANKS http://s1.co", # i like this, i'm happy about this "THANKS http://s1.co @alice", # i like this thing alice did, thanks alice "THANKS http://s1.co @alice @bob", #bob says alice is thankfull "SORRY http://s1.co", # sorry for doing this thing, to the public "SORRY http://s1.co @alice", #alice, sorry i did this "SORRY http://s1.co @alcie @bob", #bob has apologized to alice ] for statement in statements: s = parser.parse(self.magic_token + " " +statement)
def not_a(self): s = parser.parse(self.magic_token + " NOTA #troll") self.assertIsInstance(s, statements.NotA) self.assertEqual(s.group, "#troll")