def buyitem(nick, message, is_whisper, match): if not is_whisper: return item_id = amount = 0 # FIXME: check if amount=0 or id=0 try: item_id = int(match.group(1)) # price = int(match.group(2)) amount = int(match.group(3)) except ValueError: mapserv.cmsg_chat_whisper(nick, "usage: !buyitem ID PRICE AMOUNT") return if s.player: whisper(nick, "I am currently trading with someone") return player_id = mapserv.beings_cache.findId(nick) if player_id < 0: whisper(nick, "I don't see you nearby") return if item_id not in selling: whisper(nick, "I don't sell that") return real_price, max_amount = selling[item_id] index = get_item_index(item_id) if index > 0: _, curr_amount = mapserv.player_inventory[index] max_amount = min(max_amount, curr_amount) else: max_amount = 0 if amount > max_amount: whisper(nick, "I don't have that many") return total_price = real_price * amount s.player = nick s.mode = "sell" s.item_id = item_id s.amount = amount s.price = total_price s.index = index mapserv.cmsg_trade_request(player_id)
def answer_random(nick, message, is_whisper, answers): resp = random.choice(answers) if is_whisper: mapserv.cmsg_chat_whisper(nick, resp) else: mapserv.cmsg_chat_message(resp)
def answer_info(nick, message, is_whisper, match): if is_whisper: mapserv.cmsg_chat_whisper(nick, "answer to !info") else: mapserv.cmsg_chat_message("You are too curious, {}".format(nick))
def send_whisper(nick, message): sent_whispers.append((nick, message)) mapserv.cmsg_chat_whisper(nick, message)
def send_whisper(to_, msg): global whisper_to, whisper_msg whisper_to = to_ whisper_msg = msg mapserv.cmsg_chat_whisper(to_, msg)
def send_whisper(nick, message): badge.is_afk = False ts = time.time() sent_whispers.append((nick, message, ts)) mapserv.cmsg_chat_whisper(nick, message)