<?php
require_once 'qqrobot.fun.php';

class plugin_qqrobot {
	function plugin_qqrobot(){

	}
}

class plugin_qqrobot_forum extends plugin_qqrobot{

	function post_sync_to_qqrobot_aftersubmit(){
		global $_G;
		$msgforwardSet = (array)@unserialize($_G['setting']['msgforward']);
		$msgforwardSet['refreshtime'] = 3;  //只能是大于0的整数
		$msgforwardSet['quick'] = 0;
		$_G['setting']['msgforward'] = serialize($msgforwardSet);
	}

	function post_qqrobot_aftersubmit_output(){
			global $_G;
			if( $_G['gp_action'] == 'newthread' && submitcheck('topicsubmit', 0, $GLOBALS['seccodecheck'], $GLOBALS['secqaacheck'])){
			$tid = isset($GLOBALS['tid'])  ? (int)$GLOBALS['tid'] : 0;
			$pid = isset($GLOBALS['pid'])  ? (int)$GLOBALS['pid'] : 0;

			if( $tid >= 1 && $pid >= 1 ){
				$msg = $_G['setting']['bbname'].' 有新帖：'.(string)$_G['subject'].$_G['setting']['discuzurl'].'/forum.php?mod=viewthread&tid='.$tid;
				qqrobot::send(1, $_G['cache']['plugin']['qqrobot']['qq'], $msg);
			}
			return null;
		}elseif(  $_G['gp_action'] == 'reply' && submitcheck('replysubmit', 0, $GLOBALS['seccodecheck'], $GLOBALS['secqaacheck'])  ){
			$tid = isset($_G['gp_tid']) ? (int)$_G['gp_tid'] : 0;
			$pid = isset($GLOBALS['pid']) ? (int)$GLOBALS['pid'] : 0;
			if( $tid >= 1 && $pid >= 1 ){
				$qq = DB::result_first("SELECT a.qq FROM ".DB::table('qqrobot_qq')." a,".DB::table('forum_post')." b where b.first=1 and b.tid=$tid and a.uid=b.authorid");
				if(!empty($qq))
				{
					$msg = '您的帖子有新的回复，请注意查看：'.$_G['setting']['discuzurl'].'/forum.php?mod=viewthread&tid='.$tid;

					qqrobot::send(0, $qq, $msg);
				}
			}
			return null;
		
		
		}
	}
	
}


?>

