python qqbot 简易复读机

本文介绍了一款基于smartQQ的QQBot简易插件,该插件实现了基本的复读功能,当同一消息在三秒内被重复发送超过一次时,机器人将自动复读该消息。更高级的复读功能正在开发中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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机器人就被注入了灵魂,可以实现复读功能了。后续的更为高级的复读功能正在开发中。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值