当前位置: 首页>>代码示例>>Python>>正文


Python Commons.get_random_choice方法代码示例

本文整理汇总了Python中inc.Commons.Commons.get_random_choice方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.get_random_choice方法的具体用法?Python Commons.get_random_choice怎么用?Python Commons.get_random_choice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inc.Commons.Commons的用法示例。


在下文中一共展示了Commons.get_random_choice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_random_choice [as 别名]
 def run(self, line, user_obj, destination_obj=None):
     """Simulates a typical finn in conversation. Format: finnbot"""
     ari_quotes = ["|:", "After hearing you say that, I don't think we can ever be friends",
                   "Brb, cutting down a forest", "Can't answer, I'm shaving and it'll take all day",
                   "Can't hear you over all this atheism!",
                   "Can this wait until after i've listened to this song 100 times on repeat?",
                   "Could use less degrees", "Don't want to hear it, too busy complaining about the tap water",
                   "Goony goon goon", "Hang on, I have to help some micronationalist",
                   "Hey guys, check out my desktop: http://hallo.dr-spangle.com/DESKTOP.PNG",
                   "If we get into a fight, I'll pick you up and run away",
                   "I happen to be an expert on this subject", "I think I've finished constructing a hate engine",
                   "It's about time for me to play through adom again", "It's kind of hard to type while kneeling",
                   "I wish I could answer, but i'm busy redditing", "*lifeless stare*", "Lol, perl",
                   "Lol, remember when i got eli to play crawl for a week?", "Needs moar haskell",
                   "NP: Bad Religion - whatever song",
                   "Remember that thing we were going to do? Now I don't want to do it", "Smells like Oulu",
                   "Some Rahikkala is getting married, you are not invited",
                   "That blows, but I cannot relate to your situation", "This somehow reminds me of my army days",
                   "Whatever, if you'll excuse me, i'm gonna bike 50 kilometers",
                   "You guys are things that say things", "You're under arrest for having too much fun",
                   "I have found a new favourite thing to hate"]
     # TODO: add swear filters again sometime
     # ariswearquotes = ["FUCK. FINNISH. PEOPLE!!!", "FUCK MANNERHEIM", "YOU'RE A PERSON OF SHIT"]
     quote = Commons.get_random_choice(ari_quotes)[0]
     if quote[-1] not in ['.', '?', '!']:
         quote += '.'
     return quote
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_random_choice [as 别名]
 def run(self, event):
     choices = re.compile(', (?:or )?| or,? ', re.IGNORECASE).split(event.command_args)
     numchoices = len(choices)
     if numchoices == 1:
         return event.create_response('Please present me with more than 1 thing to choose from!')
     else:
         choice = Commons.get_random_choice(choices)[0]
         return event.create_response("I choose \"{}\".".format(choice))
开发者ID:joshcoales,项目名称:Hallo,代码行数:10,代码来源:Random.py

示例3: check_response

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_random_choice [as 别名]
 def check_response(self, input_line, user_obj, destination_obj):
     """Checks if this reply message will respond, and which response to use."""
     if self.prompt.search(input_line):
         # Pick a response
         response = Commons.get_random_choice(self.response_list)[0]
         response = response.replace("{USER}", user_obj.name)
         response = response.replace("{CHANNEL}", destination_obj.name)
         response = response.replace("{SERVER}", user_obj.server.name)
         return response
     return None
开发者ID:,项目名称:,代码行数:12,代码来源:

示例4: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_random_choice [as 别名]
 def run(self, event):
     # Load XML
     doc = minidom.parse("store/pokemon/pokemon.xml")
     pokemon_list_elem = doc.getElementsByTagName("pokemon_list")[0]
     pokemon_list = []
     # Loop through pokemon, adding to pokemon_list
     for pokemon_elem in pokemon_list_elem.getElementsByTagName("pokemon"):
         pokemon_dict = {'name': pokemon_elem.getElementsByTagName("name")[0].firstChild.data}
         pokemon_list.append(pokemon_dict)
     random_pokemon = Commons.get_random_choice(pokemon_list)[0]
     return event.create_response("I choose you, {}!".format(random_pokemon['name']))
开发者ID:joshcoales,项目名称:Hallo,代码行数:13,代码来源:Pokemon.py

示例5: test_get_random_choice

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_random_choice [as 别名]
 def test_get_random_choice(self):
     for count in range(1, 3):
         for max_int in range(2, 10):
             for min_int in range(1, 5):
                 if min_int > max_int:
                     continue
                 input_list = list(range(min_int, max_int+1))
                 rand_list = Commons.get_random_choice(input_list, count)
                 assert len(rand_list) == count, "Random choice list is the wrong length. " + str(rand_list) + \
                                                 " not " + str(count) + " elements"
                 for rand in rand_list:
                     assert rand in input_list, "Random choice was not in the list. " + \
                                                str(rand) + " not in " + str(input_list)
开发者ID:joshcoales,项目名称:Hallo,代码行数:15,代码来源:testCommons.py


注:本文中的inc.Commons.Commons.get_random_choice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。