qqbot 简易小插件:
具体的插件用法请访问qqbot github
基于smartQQ的qqbot 已经被弃用
from datetime import datetime
import time
def onQQMessage(bot,contact,member,content):
if content == '-hello':
bot.SendTo(contact,'你好我是机器人')
elif content == '-stop':
bot.SendTo(contact, '你好我关了哦。')
bot.Stop()
tempWord = ''
tempTime = 0
times = 0
lastContent = ""
def onQQMessage(bot,contact,member,content):
global tempWord
global tempTime
global times
now = time.time()
print(times)
if times > 20: #当复读超过20次的时候就不要复读了
print('times > 10')
return -1
elif (now - tempTime) > 3000:
print('times more than 3s')
elif (now - tempTime) <= 3000: #三秒内有人复读则启动复读程序
if(tempWord == content):#当前内容与之前的一份内容一样启动复读
bot.SendTo(contact,content)
times += 1
tempWord = ''
return
else:
tempWord = content
else:
print('it wont happen')
tempTime = float(now)
启动并且注册插件之后,qq机器人就被注入了灵魂,可以实现复读功能了。后续的更为高级的复读功能正在开发中。