擅长:python、mysql、java
<p>这是我在我的机器人上对游戏命令使用的一种方法,可以对命令进行延时。在</p>
<pre><code>import time
time_dict = dict()
class Bot(ch.RoomManager)
def onMessage(self, room, user, message):
s = message.body
if 'test' in s:
try:
if room in time_dict:
timeset = time_dict[room]
else:
timeset = time.time()-3
time_dict[room] = timeset
if time.time() - float(timeset) < 150:
return
else:
room.message("This is a sample.")
</code></pre>