示例#1
0
def changeTargetPlace(placeRaw: str):
    global state
    placeList = placeRaw.split()
    place = Place(int(placeList[0]), int(placeList[1]))
    if place in state.places:
        target = reSub(r"^[+]", "", state.places[place].name)
        state = state._replace(target=target)
        tfeval("/trigger You are now target-healing {0}.".format(target))
示例#2
0
    def getCinemaUrl(self, cinemaData):
        '''
        `cinemaData` is similar to below:

        {"CC":"PVR","ST":"NS","REGION_SLUG":"","GRP":"Venue","EVENTSTRTAGS":[],"RATING":"","L_URL":"","WTS":"","TITLE":"PVR: Forum Mall, Koramangala","ID":"PVBN","TYPE_NAME":"Venues","TYPE":"|MT|","CAT":""}
        '''

        curDate = datetime.now().strftime(
            "%Y%m%d") if self.date is None else self.date
        cinemaName = reSub('[^0-9a-zA-Z ]+', '',
                           cinemaData.get('TITLE')).lower().replace(" ", "-")

        cinemaUrl = "https://in.bookmyshow.com/buytickets/"
        cinemaUrl += cinemaName
        cinemaUrl += "/cinema-" + self.regionData.get('code').lower() + "-"
        cinemaUrl += cinemaData.get('ID')
        cinemaUrl += "-MT/"
        cinemaUrl += curDate
        return cinemaUrl
示例#3
0
    def getMovieUrl(self, movieData):
        '''
        `movieData` is similar to below:

        {'ST': 'NS', 'GRP': 'Event', 'IS_NEW': False, 'L_URL': '', 'DESC': ['Chris Evans', ' Robert Downey Jr.'], 'CODE': 'EG00068832', 'REGION_SLUG': '', 'EVENTSTRTAGS': [], 'IS_TREND': False, 'RATING': '', 'WTS': '9,14,847', 'TITLE': 'Avengers: Endgame', 'ID': 'ET00090482', 'TYPE': 'MT', 'TYPE_NAME': 'Movies', 'CAT': ''}
        '''

        curDate = datetime.now().strftime(
            "%Y%m%d") if self.date is None else self.date
        movieName = reSub('[^0-9a-zA-Z ]+', '',
                          movieData.get('TITLE')).lower().replace(" ", "-")

        movieUrl = "https://in.bookmyshow.com/buytickets/"
        movieUrl += movieName
        movieUrl += "-" + self.regionData.get(
            'alias') + "/movie-" + self.regionData.get('code').lower() + "-"
        movieUrl += movieData.get('ID')
        movieUrl += "-MT/"
        movieUrl += curDate
        return movieUrl
示例#4
0
 def save(self):
     """ save in-memory configuration to file on disk """
     try:  # Read the file in buffer
         with open(self.fileName, 'rt') as cf:
             buf = cf.read()
     except:
         LOGGER.warning(
             'Config file access error, a new file (%s) will be created',
             self.fileName)
         buf = ''
     buf = reSub(r'[\n]*$', '\n',
                 buf)  # Remove all ending blank lines except the one.
     for key, value in self.items():
         if value is None:
             res = ''  # Remove 'key=value' from file if value is None
             LOGGER.debug('Config value \'%s\' will be removed', key)
         else:  # Make a line with value
             res = self.delimiter.join(
                 [key, ', '.join(self.encode(val)
                                 for val in CVal(value))]) + '\n'
             LOGGER.debug('Config value to save: %s', res[:-1])
         # Find line with key in file the buffer
         sRe = reSearch(r'^[ \t]*["]?%s["]?[ \t]*%s.+\n' %
                        (key, self.delimiter),
                        buf,
                        flags=reM)
         if sRe is not None:  # Value has been found
             buf = sRe.re.sub(res, buf)  # Replace it with new value
         elif res != '':  # Value was not found and value is not empty
             buf += res  # Add new value to end of file buffer
     try:
         with open(self.fileName, 'wt') as cf:
             cf.write(buf)  # Write updated buffer to file
     except:
         LOGGER.error('Config file write error: %s', self.fileName)
         return False
     LOGGER.info('Config written: %s', self.fileName)
     self.changed = False  # Reset flag of change in not stored config
     return True
示例#5
0
文件: index.py 项目: Zichen3317/Slime
                try:
                    setting = fcPreset.Read(filepath)
                    Range = setting[0].split('|')[1]
                    Num = int(setting[1].split('|')[1])
                    if setting[2].split('|')[0].split(';')[1] == 'T':  # 过滤
                        filterPath = setting[2].split('|')[1]
                        filterRule = 'T'
                        filterResult = fcRandom.RD(Range,
                                                   Num,
                                                   'Random',
                                                   filterRule,
                                                   filterPath)
                        if setting[3].split('|')[0].split(';')[1] == 'T':  # 表格
                            formPath = setting[3].split('|')[1]
                            print(color.bold + color.cyan + '抽取结果:%s' % reSub(r'[\[\]\']', '', str(fcRandom.FormProcessing(filterResult,
                                                                                                                           formPath,
                                                                                                                           'Random'))))
                        else:
                            print(color.bold + color.cyan + '抽取结果:%s' % reSub(
                                r'[\[\]\']', '', str(filterResult)))

                    else:
                        filterRule = 'F'
                        filterResult = fcRandom.RD(Range,
                                                   Num,
                                                   'Random',
                                                   filterRule,
                                                   None)
                        if setting[3].split('|')[0].split(';')[1] == 'T':
                            formPath = setting[3].split('|')[1]
                            print(color.bold + color.cyan + '抽取结果:%s' % reSub(r'[\[\]\']', '', str(fcRandom.FormProcessing(
示例#6
0
文件: index.py 项目: Zichen3317/Slime
            continueCommand = console.input('[bold #436dc6]是否继续抽取?(Y/N)\n<<<')
            if continueCommand.upper() == 'Y':
                try:
                    setting = fcPreset.Read(filepath)
                    Range = setting[0].split('|')[1]
                    Num = int(setting[1].split('|')[1])
                    if setting[2].split('|')[0].split(';')[1] == 'T':  # 过滤
                        filterPath = setting[2].split('|')[1]
                        filterRule = 'T'
                        filterResult = fcRandom.RD(Range, Num, 'Random',
                                                   filterRule, filterPath)
                        if setting[3].split('|')[0].split(';')[1] == 'T':  # 表格
                            formPath = setting[3].split('|')[1]
                            console.print('[bold #ffb74d]抽取结果:%s' % reSub(
                                r'[\[\]\']', '',
                                str(
                                    fcRandom.FormProcessing(
                                        filterResult, formPath, 'Random'))))
                        else:
                            console.print(
                                '[bold #ffb74d]抽取结果:%s' %
                                reSub(r'[\[\]\']', '', str(filterResult)))

                    else:
                        filterRule = 'F'
                        filterResult = fcRandom.RD(Range, Num, 'Random',
                                                   filterRule, None)
                        if setting[3].split('|')[0].split(';')[1] == 'T':
                            formPath = setting[3].split('|')[1]
                            console.print('[bold #ffb74d]抽取结果:%s' % reSub(
                                r'[\[\]\']', '',