MCPcopy
hub / github.com/InstaPy/InstaPy / get_action_delay

Function get_action_delay

instapy/util.py:2061–2109  ·  view source on GitHub ↗

Get the delay time to sleep after doing actions

(action)

Source from the content-addressed store, hash-verified

2059
2060
2061def get_action_delay(action):
2062 """Get the delay time to sleep after doing actions"""
2063 defaults = {"like": 2, "comment": 2, "follow": 3, "unfollow": 10, "story": 3}
2064 config = Settings.action_delays
2065
2066 if (
2067 not config
2068 or action not in config
2069 or config["enabled"] is not True
2070 or config[action] is None
2071 or isinstance(config[action], (int, float)) is not True
2072 ):
2073 return defaults[action]
2074
2075 else:
2076 custom_delay = config[action]
2077
2078 # randomize the custom delay in user-defined range
2079 if (
2080 config["randomize"] is True
2081 and isinstance(config["random_range"], tuple)
2082 and len(config["random_range"]) == 2
2083 and all(
2084 (isinstance(i, (type(None), int, float)) for i in config["random_range"])
2085 )
2086 and any(not isinstance(i, type(None)) for i in config["random_range"])
2087 ):
2088 min_range = config["random_range"][0]
2089 max_range = config["random_range"][1]
2090
2091 if not min_range or min_range < 0:
2092 min_range = 100
2093
2094 if not max_range or max_range < 0:
2095 max_range = 100
2096
2097 if min_range > max_range:
2098 a = min_range
2099 min_range = max_range
2100 max_range = a
2101
2102 custom_delay = random.uniform(
2103 custom_delay * min_range / 100, custom_delay * max_range / 100
2104 )
2105
2106 if custom_delay < defaults[action] and config["safety_match"] is not False:
2107 return defaults[action]
2108
2109 return custom_delay
2110
2111
2112def deform_emojis(text):

Callers 5

follow_userFunction · 0.85
unfollow_userFunction · 0.85
comment_imageFunction · 0.85
like_imageFunction · 0.85
watch_storyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected