hxp
2019-09-20 67bcc2ab06912fc3d9cf31ceae533da76e50d5ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_BroadCast.py
# @todo: gm¹ã²¥
#
# @author: wdb
# @date 2012-06-14 
# @version 1.5
#
# @note: 
# @change: "2012-06-15 16:00" wdb É¾³ýlog 
# @change: "2012-07-12 18:00" wdb ×Ö·ûת»»ÔÚÈë¿Ú´¦Àí
# @change: "2012-07-30 11:30" wdb GM»Ø¸´Ï¸»¯£¬´úÂëÓÅ»¯
# @change: "2012-08-10 15:00" zhangxi ÐÞ¸ÄOSS¼Ç¼
# @change: "2015-01-14 11:30" hxp Ã»ÓÐÉèÖÃʱ¼äĬÈÏÁ¢¼´¹ã²¥Ò»´Î
#---------------------------------------------------------------------
"""Version = 2015-01-14 11:30"""
#---------------------------------------------------------------------
import GameWorld
import GMCommon
import DataRecordPack
import ChConfig
 
import datetime
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ(ÕâÀïcurPlayer = None)
## Ö´ÐÐÂß¼­
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param gmList [cmdIndex gmAccID forbidAcc]
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(orderId, gmCmdDict):
    
    broadCastMsg = gmCmdDict.get(GMCommon.Def_GMKey_BroadCastMsg, '')
    startTime = gmCmdDict.get(GMCommon.Def_GMKey_StartTime, '')
    endTime = gmCmdDict.get(GMCommon.Def_GMKey_EndTime, '')
    
    startDate = gmCmdDict.get(GMCommon.Def_GMKey_StartDate, '')
    endDate = gmCmdDict.get(GMCommon.Def_GMKey_EndDate, '')
    interval = GameWorld.ToIntDef(gmCmdDict.get(GMCommon.Def_GMKey_Interval, '1'), 1)
    interval = max(1, interval)
    isDelOthers = gmCmdDict.get(GMCommon.Def_GMKey_IsDelOthers, 0) == "on"
    
    if startDate == '' or startTime == '' or endDate == '' or endTime == '':
        # Ã»ÓÐÉèÖÃʱ¼ä£¬Ä¬ÈÏÁ¢¼´¹ã²¥Ò»´Î
        startTime = GameWorld.GetCurrentDataTimeStr()
        endTime = str(GameWorld.GetServerTime() + datetime.timedelta(seconds=59))
        endTime = endTime.strip().split(".")[0]
    else:
        startTime = startDate + " " + startTime
        endTime = endDate + ' ' + endTime
    
    # É¾³ý֮ǰµÄ´æ´¢µÄ¹ã²¥
    if isDelOthers:
        GMCommon.DelAllBroadCast()
    
    elif broadCastMsg == '' or endTime == '' or startTime == '':
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)    
        return
    
    startDate = GameWorld.GetDateTimeByFormatStr(startTime, ChConfig.TYPE_Time_Format)
    endDate = GameWorld.GetDateTimeByFormatStr(endTime, ChConfig.TYPE_Time_Format)
    dateTime = GameWorld.GetServerTime()
 
    # ÅжÏʱ¼äÊÇ·ñÕýÈ·
    if CheckDate(startDate, endDate) or CheckDate(dateTime, endDate):
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_InvalidTime)   
        return
 
    startTime = GameWorld.ChangeTimeStrToNum(startTime)
    endTime = GameWorld.ChangeTimeStrToNum(endTime)
    
    # ·¢ËÍÏûÏ¢
    GMCommon.SetBroadCastInfo(startTime, endTime, interval,
                               broadCastMsg, isDelOthers)
    #Ö´Ðгɹ¦
    GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success)    
    # Á÷Ïò
    DataRecordPack.DR_ToolGMOperate(0, '', '', 'GMT_BroadCast', str(gmCmdDict))
    return
 
 
## ÅжÏʱ¼äÊÇ·ñ´íÎó
#  @param startDate£ºÏà¶ÔСÈÕÆÚ
#  @param endDate£ºÏà¶Ô´óÈÕÆÚ
#  @return None
def CheckDate(startDate, endDate):
    
    if (endDate - startDate).days < 0:
        return True
    
    return False