Beispiel #1
0
def run(robot, channel, tokens, user, command):
    ''''''
    jsonFile = CACHE_DEFAULT_URL + str(channel) + '.json'
    stat, stat_msg, channelInfo = checkStatus(channel, tokens, GAME_NAME)
    if stat == -1:      # Error
        return channel, stat_msg
    elif stat == 1:     # Need to initialize
        gameInit(channelInfo)

    userName = get_nickname(user)
    if not channelInfo['member'][channelInfo['index']] == userName:
        return channel, getMessage(MESSAGE_TYPE_CURRENT_USER, channel=channel)
    if not len(tokens[0]) == channelInfo['digit']:  # or isNumber(tokens[0])
        return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
    strike, ball = 0, 0
    for number in tokens[0]:
        if number == channelInfo['answer'][tokens[0].index(number)]:
            strike += 1
        elif number in channelInfo['answer']:
            ball += 1
    if strike == channelInfo['digit']:
        os.remove(CACHE_DEFAULT_URL + str(channel) + '.json')
        return channel, '정답. 게임종료'
    else:
        channelInfo['index'] += 1
        channelInfo['index'] %= len(channelInfo['member'])
        with open(jsonFile, 'w') as fp:
            json.dump(channelInfo, fp, indent=4)
        result = 'S' + str(strike) + ' B' + str(ball)
        next_user = getMessage(MESSAGE_TYPE_CURRENT_USER, channel=channel)
        return channel, result + '\n' + next_user
    return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
Beispiel #2
0
def run(robot, channel, tokens, user, command):
    ''''''
    jsonFile = CACHE_DEFAULT_URL + str(channel) + '.json'
    stat, stat_msg, channelInfo = checkStatus(channel, tokens, GAME_NAME)
    if stat == -1:  # Error
        return channel, stat_msg
    elif stat == 1:  # Need to initialize
        gameInit(channelInfo)

    userName = get_nickname(user)
    if not channelInfo['member'][channelInfo['index']] == userName:
        return channel, getMessage(MESSAGE_TYPE_CURRENT_USER, channel=channel)
    if not len(tokens[0]) == channelInfo['digit']:  # or isNumber(tokens[0])
        return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
    strike, ball = 0, 0
    for number in tokens[0]:
        if number == channelInfo['answer'][tokens[0].index(number)]:
            strike += 1
        elif number in channelInfo['answer']:
            ball += 1
    if strike == channelInfo['digit']:
        os.remove(CACHE_DEFAULT_URL + str(channel) + '.json')
        return channel, '정답. 게임종료'
    else:
        channelInfo['index'] += 1
        channelInfo['index'] %= len(channelInfo['member'])
        with open(jsonFile, 'w') as fp:
            json.dump(channelInfo, fp, indent=4)
        result = 'S' + str(strike) + ' B' + str(ball)
        next_user = getMessage(MESSAGE_TYPE_CURRENT_USER, channel=channel)
        return channel, result + '\n' + next_user
    return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
Beispiel #3
0
def run(robot, channel, tokens, user, command):
    '''일정시간 이후에 알람 울려줌'''
    msg = '사용법 오류'
    if len(tokens) > 1:
        user_name = get_nickname(user)
        sec = int(eval(tokens[0]))
        noti_msg = user_name + ', ' + str(sec) + '초 후에 알려주겠음.'
        send_msg(robot, channel, noti_msg)
        time.sleep(sec)
        msg = '<@' + user + '>, ' + cat_token(tokens, 1)
    return channel, msg
Beispiel #4
0
def run(robot, channel, tokens, user, command):
    '''단어 기억해드림'''
    msg = ''
    if len(tokens) == 0:
        msg = '`!기억` 에 대한 사용법은 `!도움 기억`을 통해 볼 수 있음'
        return channel, msg
    nickname = get_nickname(user)
    if os.path.exists('./apps/name_cache/' + str(tokens[0])):
        f = open('./apps/name_cache/' + str(tokens[0]), 'r')
    else:
        f = None
    full_line = ''
    if len(tokens) == 1:
        if str(tokens[0]) == '?':
            all_file = os.listdir('./apps/name_cache/')
            msg = '제가 여태까지 기억한 것들은 아래와 같아요!\n'
            msg += ' || '.join(all_file)
            return channel, msg
        if not f:
            msg = str(tokens[0]) + '에 대해 기억나는게 없어요 ㅠㅡㅠ'
            return channel, msg
        time = line = f.readline()
        while line:
            line = f.readline()
            full_line += line
        msg = full_line + '\n' + time
    elif len(tokens) > 1:
        if f:
            line = f.readline()
            while line:
                line = f.readline()
                full_line += line
        full_line = '가장 최근에 ' + insert_dot(nickname) + '이(가) ' + strftime(
            '%Y-%m-%d %H:%M:%S', localtime()) + '에 알려줬어요!\n' + full_line
        desc = ''
        for i in range(1, len(tokens)):
            desc += tokens[i] + ' '
        full_line = full_line + desc[:-1] + '\n'
        if f:
            f.close()
        f = open('./apps/name_cache/' + str(tokens[0]), 'w')
        f.write(full_line)
        f.close()
        msg = str(tokens[0]) + '에 대해 ' + desc[:-1] + '(이)라고 기억했어요!'
    return channel, msg
Beispiel #5
0
def run(robot, channel, tokens, user, command):
    '''단어 기억해드림'''
    msg = ''
    if len(tokens) == 0:
        msg = '`!기억` 에 대한 사용법은 `!도움 기억`을 통해 볼 수 있음'
        return channel, msg
    nickname = get_nickname(user)
    if os.path.exists('./apps/name_cache/'+str(tokens[0])):
        f = open('./apps/name_cache/'+str(tokens[0]), 'r')
    else:
        f = None
    full_line = ''
    if len(tokens) == 1:
        if str(tokens[0]) == '?':
            all_file = os.listdir('./apps/name_cache/')
            msg = '제가 여태까지 기억한 것들은 아래와 같아요!\n'
            msg += ' || '.join(all_file)
            return channel, msg
        if not f:
            msg = str(tokens[0])+'에 대해 기억나는게 없어요 ㅠㅡㅠ'
            return channel, msg
        time = line = f.readline()
        while line:
            line = f.readline()
            full_line += line
        msg = full_line+'\n'+time
    elif len(tokens)>1:
        if f:
            line = f.readline()
            while line:
                line = f.readline()
                full_line += line
        full_line = '가장 최근에 '+insert_dot(nickname)+'이(가) '+strftime('%Y-%m-%d %H:%M:%S', localtime())+'에 알려줬어요!\n'+full_line
        desc = ''
        for i in range(1, len(tokens)):
            desc += tokens[i]+' '
        full_line = full_line+desc[:-1]+'\n'
        if f:
            f.close()
        f = open('./apps/name_cache/'+str(tokens[0]), 'w')
        f.write(full_line)
        f.close()
        msg = str(tokens[0])+'에 대해 '+desc[:-1]+'(이)라고 기억했어요!'
    return channel, msg
Beispiel #6
0
def run(robot, channel, tokens, user, command):
    ''''''
    info_file = CACHE_PATH + channel + '.json'
    nickname = get_nickname(user)
    qdat = {}
    if len(tokens) < 1:
        return channel, '자세한 사용법은 ... `!도움 퀴즈`'

    if os.path.isfile(info_file):
        cdat = json.loads(open(info_file).read())
        quizRaw = open(CATEGORY_PATH + cdat['category'] + '.json').read()
        qdat = json.loads(quizRaw)
        answer, hint = get_answer(channel)
        msg = json.loads(open(CACHE_PATH + 'attach.json').read())
        try_answer = re.sub(r'\s*\*\s*|~|\?|\[|\]|♥|\.|!|_|,|\s', '', cat_token(tokens,0))
        comp_answer = re.sub(r'\s*\*\s*|~|\?|\[|\]|♥|\.|!|_|,|\s', '', answer)
        msg[0]['author_link'] += nickname
        msg[0]['author_name'] = nickname
        msg[0]['author_icon'] = get_userinfo(user, ['profile', 'image_32'])
        msg[0]['title'] = answer
        msg[0]['text'] = hint
		#msg[0]['field'] = ...
        #msg = '정답은 `'+answer+'` '+hint+' (출제:'+insert_dot(qdat['user'][cdat['q_num']-1])+')\n'

        if comp_answer.lower() == try_answer.lower():
            #msg = ':o: ' + insert_dot(nickname) + ', 맞았음. \n'+msg
            msg[0]['color'] = '#0fb5a1'
            msg[0]['thumb_url'] = 'http://feonfun.com/o_mark.png'
            cdat['correct'] += 1
            if nickname in cdat['correct_user']:
                cdat['correct_cnt'][cdat['correct_user'].index(nickname)] += 1
            else:
                cdat['correct_user'].append(nickname)
                cdat['correct_cnt'].append(1)
        else:
            if channel[0] == 'C':
                msg = ':x: '+insert_dot(nickname)+', 틀렸음.'
                return channel, msg
            else:
                msg = ':x: '+insert_dot(nickname)+', 틀렸음. \n'+msg
        with open(info_file, 'w') as fp:
            json.dump(cdat, fp, indent=4)
        if not get_random_question(channel):    # failed to get question(fin.)
            tim = cdat['start_time'].split(' ')
            dt_i = datetime(int(tim[0]), int(tim[1]), int(tim[2]), int(tim[3]), int(tim[4]), int(tim[5]), 0)
            dt_f = datetime.today()
            dt = dt_f - dt_i
            sec = dt.total_seconds()
            elap = ''
            if sec // 86400 != 0 :
                elap += str(int(sec // 86400))+'일, '+str(int((sec % 86400) // 3600))+'시간 '+str(int((sec % 3600) // 60))+'분 '+str(int(sec % 60))+'초'
            elif sec // 3600 != 0:
                elap += str(int((sec % 86400) // 3600))+'시간 '+str(int((sec % 3600) // 60))+'분 '+str(int(sec % 60))+'초'
            elif sec // 60 != 0:
                elap += str(int((sec % 3600) // 60))+'분 '+str(int(sec % 60))+'초'
            else:
                elap += str(int(sec % 60))+'초'
            msg[0]['text'] += '\n문제집 내의 모든 문제를 품. '+str(cdat['correct'])+'/'+str(cdat['q_max'])+'문제 정답. (소요시간 : '+elap+')\n'
            userlist = cdat['correct_user']
            countlist = cdat['correct_cnt']
            if len(userlist) > 0:
                countlist, userlist = zip(*sorted(zip(countlist, userlist), reverse=True))
                for user in userlist:
                    if userlist.index(user) == 0:
                        msg[0]['text'] += ':trophy:  '+insert_dot(user) +': '+str(countlist[userlist.index(user)])+'문제\n'
                    else:
                        msg[0]['text'] += ' '*9+insert_dot(user) +': '+str(countlist[userlist.index(user)])+'문제\n'
            os.remove(info_file)
            return channel, msg
        else:
            send_msg(robot, channel, attachments=msg)
            time.sleep(1)
            msg = get_message(channel)
    else:
        return channel, '진행중인 문제집이 없음. 자세한 사용법은...(`!도움 퀴즈`)'
    return channel, msg
Beispiel #7
0
def run(robot, channel, tokens, user, command):
    ''''''
    json_file = CACHE_DEFAULT_URL + '_' + channel
    msg = '단어를 말해야...'
    if len(tokens) < 1:
        return channel, msg
    if len(tokens[0]) < 2:
        msg = '두 글자 이상의 단어만 가능함'
        return channel, msg
    if tokens[0] == '포기할래':
        if os.path.exists(json_file):
            game_info = json.loads(open(json_file).read())
            score = game_info['score']
            os.remove(json_file)
            save_rank('bot', score)
            msg = 'ㅎㅎ 내가이김. (승규의 점수: ' + str(score) + ')\n'
            rank_msg = '\n'
            if 'user' in game_info:
                for user, score in game_info['user'].items():
                    rank_msg += get_nickname(user) + ' : ' + str(score) + '점\n'
            rank_msg += '(패배시에는 점수가 반영되지 않음)\n'
            top_name, top_score = get_highest_rank()
            if top_name:
                msg += '> :crown: 끝말잇기의 달인 : ' + top_name + ' (' + str(top_score) + '점)'
            msg += rank_msg
            return channel, msg
        else:
            msg = '시작한것도 없음'
            return channel, msg
    if not is_koreanword(tokens[0]):
        msg = '단어가 아님'
        return channel, msg
    wdat = {}
    if os.path.exists(WORD_DEFAULT_URL):
        wdat = json.loads(open(WORD_DEFAULT_URL).read())
    if tokens[0] not in wdat:
        wdat[tokens[0]] = 0
    wdat[tokens[0]] += 1
    with open(WORD_DEFAULT_URL, 'w') as fp:
        json.dump(wdat, fp, indent=4)
    msg = ''
    game_info = {}
    word_info = json.loads(open(WORD_DEFAULT_URL).read())
    if os.path.exists(json_file):
        game_info = json.loads(open(json_file).read())
        if tokens[0] in game_info['used_word']:
            msg = '이미 썼던 단어임'
            return channel, msg
        if tokens[0][0] not in game_info['start_word']:
            msg = '끝말잇기를 해야지! (현재 단어: ' + game_info['last_word'] + ')'
            return channel, msg
        add_score(user, game_info)
        game_info['used_word'].append(tokens[0])
    else:
        msg += '새로운 끝말잇기를 시작함\n'
        add_score(user, game_info)
        game_info['used_word'] = [tokens[0]]
    start_word = get_startword(tokens[0])
    candidate_word = []
    my_word = ''
    for word in word_info.keys():
        if word[0] in start_word and word not in game_info['used_word']:
            for i in range(word_info[word]):
                candidate_word.append(word)
    if candidate_word:
        my_word = random.choice(candidate_word)
        game_info['last_word'] = my_word
        game_info['used_word'].append(my_word)
        game_info['start_word'] = get_startword(my_word)
        if 'score' in game_info:
            game_info['score'] += 1
        else:
            game_info['score'] = 1
        with open(json_file, 'w') as fp:
            json.dump(game_info, fp, indent=4)
        msg += my_word
    else:
        msg += '내가 짐.\n'
        rank_msg = '\n'
        if 'user' in game_info:
            for user, score in game_info['user'].items():
                rank_msg += get_nickname(user) + ' : ' + str(score) + '점\n'
                save_rank(user, score)
        top_name, top_score = get_highest_rank()
        if top_name:
            msg += '> :crown: 끝말잇기의 달인 : ' + top_name + ' (' + str(top_score) + '점)'
        msg += rank_msg
        if os.path.exists(json_file):
            os.remove(json_file)
    return channel, msg
Beispiel #8
0
def run(robot, channel, tokens, user, command):
    ''''''
    json_file = CACHE_DEFAULT_URL + '_' + channel
    msg = '단어를 말해야...'
    if len(tokens) < 1:
        return channel, msg
    if len(tokens[0]) < 2:
        msg = '두 글자 이상의 단어만 가능함'
        return channel, msg
    if tokens[0] == '포기할래':
        if os.path.exists(json_file):
            game_info = json.loads(open(json_file).read())
            score = game_info['score']
            os.remove(json_file)
            save_rank('bot', score)
            msg = 'ㅎㅎ 내가이김. (승규의 점수: ' + str(score) + ')\n'
            rank_msg = '\n'
            if 'user' in game_info:
                for user, score in game_info['user'].items():
                    rank_msg += get_nickname(user) + ' : ' + str(score) + '점\n'
            rank_msg += '(패배시에는 점수가 반영되지 않음)\n'
            top_name, top_score = get_highest_rank()
            if top_name:
                msg += '> :crown: 끝말잇기의 달인 : ' + top_name + ' (' + str(
                    top_score) + '점)'
            msg += rank_msg
            return channel, msg
        else:
            msg = '시작한것도 없음'
            return channel, msg
    if not is_koreanword(tokens[0]):
        msg = '단어가 아님'
        return channel, msg
    wdat = {}
    if os.path.exists(WORD_DEFAULT_URL):
        wdat = json.loads(open(WORD_DEFAULT_URL).read())
    if tokens[0] not in wdat:
        wdat[tokens[0]] = 0
    wdat[tokens[0]] += 1
    with open(WORD_DEFAULT_URL, 'w') as fp:
        json.dump(wdat, fp, indent=4)
    msg = ''
    game_info = {}
    word_info = json.loads(open(WORD_DEFAULT_URL).read())
    if os.path.exists(json_file):
        game_info = json.loads(open(json_file).read())
        if tokens[0] in game_info['used_word']:
            msg = '이미 썼던 단어임'
            return channel, msg
        if tokens[0][0] not in game_info['start_word']:
            msg = '끝말잇기를 해야지! (현재 단어: ' + game_info['last_word'] + ')'
            return channel, msg
        add_score(user, game_info)
        game_info['used_word'].append(tokens[0])
    else:
        msg += '새로운 끝말잇기를 시작함\n'
        add_score(user, game_info)
        game_info['used_word'] = [tokens[0]]
    start_word = get_startword(tokens[0])
    candidate_word = []
    my_word = ''
    for word in word_info.keys():
        if word[0] in start_word and word not in game_info['used_word']:
            for i in range(word_info[word]):
                candidate_word.append(word)
    if candidate_word:
        my_word = random.choice(candidate_word)
        game_info['last_word'] = my_word
        game_info['used_word'].append(my_word)
        game_info['start_word'] = get_startword(my_word)
        if 'score' in game_info:
            game_info['score'] += 1
        else:
            game_info['score'] = 1
        with open(json_file, 'w') as fp:
            json.dump(game_info, fp, indent=4)
        msg += my_word
    else:
        msg += '내가 짐.\n'
        rank_msg = '\n'
        if 'user' in game_info:
            for user, score in game_info['user'].items():
                rank_msg += get_nickname(user) + ' : ' + str(score) + '점\n'
                save_rank(user, score)
        top_name, top_score = get_highest_rank()
        if top_name:
            msg += '> :crown: 끝말잇기의 달인 : ' + top_name + ' (' + str(
                top_score) + '점)'
        msg += rank_msg
        if os.path.exists(json_file):
            os.remove(json_file)
    return channel, msg
Beispiel #9
0
def run(robot, channel, tokens, user, command):
    '''문제 내드림'''
    info_file = CACHE_DEFAULT_URL + channel + '.json'
    nickname = get_nickname(user)
    msg = ''
    if len(tokens) < 1:
        return channel, get_message(channel)

    if tokens[0] in ['등록', '추가']:
        if len(tokens) != 4:
            return channel, '자세한 사용법은...(`!도움 퀴즈`)'
        quizFile = CACHE_CATEGORY_URL + tokens[1] + '.json'
        qdat = {}
        if os.path.isfile(quizFile):
            qdat = json.loads(open(quizFile).read())
            qdat['q_num'] += 1
            qdat['question'].append(tokens[2])
            qdat['answer'].append(tokens[3])
            qdat['user'].append(nickname)
            qdat['time'].append(strftime('%Y-%m-%d %H:%M:%S', localtime()))
        else:
            qdat['q_num'] = 1
            qdat['question'] = [tokens[2]]
            qdat['answer'] = [tokens[3]]
            qdat['user'] = [nickname]
            qdat['time'] = [strftime('%Y-%m-%d %H:%M:%S', localtime())]
        with open(quizFile, 'w') as fp:
            json.dump(qdat, fp, indent=4)
        msg = tokens[1] + '에 관한 문제가 추가됨'

    elif tokens[0] == '수정':
        if len(tokens) != 5:
            return channel, '자세한 사용법은...(`!도움 퀴즈`)'
        quizFile = CACHE_CATEGORY_URL + tokens[1] + '.json'
        qdat = json.loads(open(quizFile).read())
        if not isNumber(tokens[2]):
            return channel, '자세한 사용법은...(`!도움 퀴즈`)'
        idx = int(tokens[2]) - 1
        quiz['question'][idx] = tokens[3]
        quiz['answer'][idx] = tokens[4]
        quiz['user'][idx] = nickname
        quiz['time'][idx] = strftime('%Y-%m-%d %H:%M:%S', localtime())
        with open(quizFile, 'w') as fp:
            json.dump(qdat, fp, indent=4)
        msg = tokens[1] + '에 관한 ' + tokens[2] + '번 문제가 수정됨'

    elif tokens[0] == '포기':
        if channel[0] == 'D':
            os.remove(info_file)
            return channel, '진행중인 퀴즈를 포기함'
        cdat = json.loads(open(info_file).read())
        if user in cdat['give_up']:
            return channel, '이미 포기에 투표함'
        if len(cdat['give_up']) < 2:
            cdat['give_up'].append(user)
            with open(info_file, 'w') as fp:
                json.dump(cdat, fp, indent=4)
            return channel, str(3 - len(cdat['give_up']))+'명 더 필요함'
        os.remove(info_file)
        msg = '진행중인 퀴즈를 포기함'

    elif tokens[0] == '조회':
        if len(tokens) < 2:
            return channel, '자세한 사용법은...(`!도움 퀴즈`)'
        if channel[0] == 'C':
            return channel, '채널에선 사용할 수 없음'
        quizFile = CACHE_CATEGORY_URL + tokens[1] + '.json'
        qdat = json.loads(open(quizFile).read())
        msg = tokens[1] + '에는 총 ' + str(qdat['q_num']) + '개의 문제가 있음'
        for idx, question in enumerate(qdat['question']):
            msg += '\n*' + str(idx + 1) + '.* ' + question

    elif tokens[0] == '문제집':
        all_file = os.listdir(CACHE_CATEGORY_URL)
        quiz_list = list(map(lambda x: os.path.splitext(x)[0], all_file))
        msg = '>*여태 등록된 문제집들*\n' + ' || '.join(quiz_list)

    elif tokens[0] == '시작':
        if len(tokens) < 2:
            return channel, '자세한 사용법은...(`!도움 퀴즈`)'
        if os.path.isfile(info_file):
            return channel, '이미 진행중인 문제집이 있음. `!퀴즈`'
        if not os.path.isfile(CACHE_CATEGORY_URL + tokens[1] + '.json'):
            return channel, '그런 문제집은 없음.'
        quizRaw = open(CACHE_CATEGORY_URL + tokens[1] + '.json').read()
        qdat = json.loads(quizRaw)
        rand_num = random.randrange(0, qdat['q_num'])
        question = qdat['question'][rand_num]
        answer = qdat['answer'][rand_num]
        cdat = {}
        cdat['name'] = nickname
        cdat['start_time'] = strftime('%Y %m %d %H %M %S', localtime())
        cdat['last_solved'] = int(round(time.time() * 1000))
        cdat['solved'] = []
        cdat['correct'] = 0
        cdat['give_up'] = []
        cdat['skip_count'] = []
        cdat['correct_user'] = []
        cdat['correct_cnt'] = []
        cdat['q_num'] = rand_num + 1
        if len(tokens) == 3:
            cdat['q_max'] = int(tokens[2])
        else:
            cdat['q_max'] = qdat['q_num']
        cdat['question'] = question
        cdat['answer'] = answer
        cdat['category'] = tokens[1]
        with open(info_file, 'w') as fp:
            json.dump(cdat, fp, indent=4)
        msg = get_message(channel)

    elif tokens[0] == '패스':
        if not os.path.isfile(info_file):
            return channel, '자세한 사용법은... `!퀴즈`'
        cdat = json.loads(open(info_file).read())
        if user in cdat['skip_count']:
            return channel, '이미 패스에 투표함'
        if len(cdat['skip_count']) < 1:
            cdat['skip_count'].append(user)
            with open(info_file, 'w') as fp:
                json.dump(cdat, fp, indent=4)
            return channel, str(2 - len(cdat['skip_count'])) + '명 더 필요함'
        quizRaw = open(CACHE_CATEGORY_URL + cdat['category'] + '.json').read()
        qdat = json.loads(quizRaw)
        answer, hint = get_answer(channel)
        msg = '정답은 `'+answer+'` '+hint+' (출제:'+qdat['user'][cdat['q_num']-1][:1]+'·'+qdat['user'][cdat['q_num']-1][1:]+')\n'
        get_random_question(channel)
        msg += get_message(channel)
    else:
        msg = '자세한 사용법은...(`!도움 퀴즈`)'
    return channel, msg
Beispiel #10
0
def run(robot, channel, tokens, user, command):
    '''게임 함'''

    jsonFile = CACHE_DEFAULT_URL + str(channel) + '.json'
    userName = get_nickname(user)
    channelInfo = {}

    if len(tokens) < 1:
        return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)

    if str(tokens[0]) in ['방생성', '생성']:  # To do: Deny DM
        if len(tokens) < 2:
            return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
        gameName = ''
        if str(tokens[1]) in GAME_LIST:
            gameName = str(tokens[1])
            if str(tokens[1]) in MODE_LIST:
                modeList = MODE_LIST[str(tokens[1])]
                for mode in modeList.values():
                    channelInfo[mode[0]] = mode[2]
                if len(tokens) > 2:
                    mode = ''
                    for token in tokens[2:]:
                        if isNumber(token):
                            if mode:
                                channelInfo[modeList[mode][0]] = int(token)
                                mode = ''
                        else:
                            mode = str(token)
                            channelInfo[modeList[mode][0]] = 1
        else:
            return channel, getMessage(MESSAGE_TYPE_GAME_NOT_EXIST)
        if not os.path.isfile(jsonFile):
            channelInfo['init'] = True
            channelInfo['index'] = 0
            channelInfo['mode'] = 0
            channelInfo['name'] = gameName
            channelInfo['status'] = STATUS_GAME_READY
            channelInfo['member'] = [userName]
            channelInfo['number'] = []
            channelInfo['reserveExit'] = []
        else:
            return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)

        with open(jsonFile, 'w') as fp:
            json.dump(channelInfo, fp, indent=4)
        return channel, getMessage(MESSAGE_TYPE_MAKE_GAME)
    else:
        if not os.path.isfile(jsonFile):
            return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)

    loadDta = open(jsonFile).read()
    channelInfo = json.loads(loadDta)

    if str(tokens[0]) in ['참가', '방참가', '참여']:
        if userName in channelInfo['member']:
            return channel, userName + getMessage(MESSAGE_TYPE_ALREADY_MEMBER)
        if channelInfo['status'] == STATUS_GAME_START:
            return channel, userName + getMessage(MESSAGE_TYPE_PLAYED_GAME)
        channelInfo['member'].append(userName)
        with open(jsonFile, 'w') as fp:
            json.dump(channelInfo, fp, indent=4)
        return channel, str(userName) + getMessage(MESSAGE_TYPE_JOIN_MEMBER)

    if str(tokens[0]) == '시작':
        if channelInfo['status'] == STATUS_GAME_START:
            return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
        gName = channelInfo['name'].encode('utf-8')
        gInfo = GAME_INFO[gName]
        if len(channelInfo['member']) < gInfo['MIN_NEED_PERSON']:
            return channel, getMessage(MESSAGE_TYPE_FEW_MEMBER, gameName=gName)
        channelInfo['status'] = STATUS_GAME_START
        with open(jsonFile, 'w') as fp:
            json.dump(channelInfo, fp, indent=4)
        return channel, getMessage(MESSAGE_TYPE_GAME_MEMBER, channel=channel)

    if str(tokens[0]) == '상태':
        return channel, getMessage(MESSAGE_TYPE_GAME_MEMBER, channel=channel)

    if str(tokens[0]) == '나가기':
        gName = channelInfo['name'].encode('utf-8')
        gInfo = GAME_INFO[gName]
        if gInfo['ALLOW_EXIT'] == 1:
            if userName in channelInfo['member']:
                channelInfo['member'].remove(userName)
                channelInfo['index'] %= len(channelInfo['member'])
                with open(jsonFile, 'w') as fp:
                    json.dump(channelInfo, fp, indent=4)
                return channel, getMessage(MESSAGE_TYPE_EXIT_MEMBER)
            else:
                return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
        else:
            # 전원 투표시 게임 종료 구현예정
            return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)
        if len(channelInfo['member']) == 0:
            os.remove(jsonFile)
            return channel, getMessage(MESSAGE_TYPE_GAME_END)

    # if str(tokens[0]) == '조회':
    return channel, getMessage(MESSAGE_TYPE_ILLEGAL_SYNTAX)