Example #1
0
 def execute(self, bot, input):
     try:
         cit_name = int(input.group(2))
     except ValueError:
         cit_name = input.group(2)
     cit = Citizen(cit_name)
     bot.say(cit.toString())
     # Store citizen for future use
     ctzns = bot.db['citizens']
     if ctzns is None:
         ctzns = []
     if cit not in ctzns:
         ctzns.append(cit)
         bot.db['citizens'] = ctzns
Example #2
0
 def execute(self, bot, input):
     try:
         cit_name = int(input.group(2))
     except ValueError:
         cit_name = input.group(2)
     if cit_name in bot.db.get('citizens', []):
         ndx = bot.db['citizens'].index(cit_name)
         cit = bot.db['citizens'][ndx]
     else:
         cit = Citizen(cit_name)
         cit.load()
         ctzns = bot.db.get('citizens', [])
         if cit not in ctzns:
             ctzns.append(cit)
             bot.db['citizens'] = ctzns
     bot.say('http://economy.erepublik.com/en/citizen/donate/%s' % cit.id)
Example #3
0
 def execute(self, bot, input):
     try:
         cit_name = int(input.group(2))
     except ValueError:
         cit_name = input.group(2)
     cit = Citizen(cit_name)
     cit.load()
     ctzns = bot.db.get('citizens', [])
     if cit not in ctzns:
         ctzns.append(cit)
         bot.db['citizens'] = ctzns
     try:
         food = float(input.group(3))
     except IndexError:
         # No food => assume 1
         food = 1
     except TypeError:
         # No food => assume 1
         food = 1
     except ValueError:
         bot.reply('Food increase "%s" is not parsable...' % input.group(3))
     try:
         house = float(input.group(4))
     except IndexError:
         # No house => assume no house (0)
         house = 0
     except TypeError:
         # No house => assume no house (0)
         house = 0
     except ValueError:
         bot.reply('House increase "%s" is not parsable...' % input.group(4))
     happiness_increase = (1.5 - (cit.happiness / 100.0)) * (food + house)
     happiness_tomorrow = cit.happiness + happiness_increase
     if happiness_tomorrow > 100:
         happiness_tomorrow = 100
     bot.reply('%s\'s happiness tomorrow will be %s (+%s)' % (cit.name,
                                                              happiness_tomorrow,
                                                              happiness_increase))