diff --git a/__init__.py b/__init__.py index c53e2fe..ea3d752 100644 --- a/__init__.py +++ b/__init__.py @@ -3,9 +3,6 @@ class AnyType(str): return False any_typ = AnyType("*") - - - from .meyo_node_Computational import * from .meyo_node_String import * from .meyo_node_File import * @@ -74,6 +71,8 @@ NODE_CLASS_MAPPINGS = { #功能型节点:meyo_node_Functional "GetCurrentTime": GetCurrentTime, + "SimpleRandomSeed": SimpleRandomSeed, + "SplitIntegers": SplitIntegers, "SelectionParameter": SelectionParameter, "ReadWebNode": ReadWebNode, } @@ -140,6 +139,9 @@ NODE_DISPLAY_NAME_MAPPINGS = { #功能型节点:meyo_node_Functional "GetCurrentTime": "当前时间(戳)🐠meeeyo.com", + "SimpleRandomSeed": "随机整数🐠meeeyo.com", + "SplitIntegers": "整数参数🐠meeeyo.com", + "SelectionParameter": "选择参数🐠meeeyo.com", "ReadWebNode": "读取页面🐠meeeyo.com", } diff --git a/meyo_node_Functional.py b/meyo_node_Functional.py index 0934099..068352c 100644 --- a/meyo_node_Functional.py +++ b/meyo_node_Functional.py @@ -2,6 +2,7 @@ import time import secrets import requests import base64 +import random from datetime import datetime from . import AnyType, any_typ @@ -30,7 +31,70 @@ class GetCurrentTime: formatted_time_with_prefix = f"{prefix} {current_time}" return (formatted_time_with_prefix, timestamp) + +#======随机整数 +class SimpleRandomSeed: + @classmethod + def INPUT_TYPES(cls): + return { + "optional": {"any": (any_typ,)} + } + + RETURN_TYPES = ("STRING", "INT") + FUNCTION = "generate_random_seed" + CATEGORY = "Meeeyo/Functional" + DESCRIPTION = "如需更多帮助或商务需求(For tech and business support)+VX/WeChat: meeeyo" + def IS_CHANGED(): + return float("NaN") + + def generate_random_seed(self, any=None): + try: + length = random.randint(8, 12) + first_digit = random.randint(1, 9) + remaining_digits = random.randint(0, 10**(length - 1) - 1) + random_seed = int(str(first_digit) + str(remaining_digits).zfill(length - 1)) + return (str(random_seed), random_seed) + + except Exception as e: + return (f"Error: {str(e)}",) + + + +#======整数参数 +class SplitIntegers: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "numbers": ("STRING", {"default": "2|3|4|5"}), # Input for the numbers separated by '|' + }, + } + + RETURN_TYPES = ("INT", "INT", "INT", "INT") + FUNCTION = "split_numbers" + CATEGORY = "Meeeyo/Functional" + DESCRIPTION = "如需更多帮助或商务需求(For tech and business support)+VX/WeChat: meeeyo" + def IS_CHANGED(): + return float("NaN") + + def split_numbers(self, numbers): + try: + parts = numbers.split('|') + result = [] + for i in range(4): + if i < len(parts) and parts[i].strip(): + try: + result.append(int(parts[i].strip())) + except ValueError: + result.append(None) + else: + result.append(None) + return tuple(result) + except Exception as e: + return (f"Error: {str(e)}", None, None, None) + + #======选择参数diy class SelectionParameter: @classmethod @@ -96,4 +160,4 @@ class ReadWebNode: response_text = f"{prefix}{response.text}{suffix}" return (response_text,) except requests.RequestException as e: - return ('Error!解析失败,请检查后重试!',) + return ('Error!解析失败,请检查后重试!',) \ No newline at end of file diff --git a/meyo_node_String.py b/meyo_node_String.py index 300d0e8..5ad035a 100644 --- a/meyo_node_String.py +++ b/meyo_node_String.py @@ -67,7 +67,7 @@ class TextConcatenator: @classmethod def INPUT_TYPES(cls): return { - "required": { + "optional": { "text1": ("STRING", {"multiline": True, "default": ""}), "text2": ("STRING", {"multiline": True, "default": ""}), "text3": ("STRING", {"multiline": True, "default": ""}), @@ -1434,4 +1434,4 @@ The following is the main content of mine: return ("",) except Exception as e: - return (f"Error: {str(e)}",) + return (f"Error: {str(e)}",) \ No newline at end of file