Less spam, easier for server.
All checks were successful
Build Ragnar anti spam bot / Build (push) Successful in 1m21s
All checks were successful
Build Ragnar anti spam bot / Build (push) Successful in 1m21s
This commit is contained in:
parent
cf7c54be63
commit
a43c13c2e5
@ -5,6 +5,7 @@ import time
|
||||
from ragnar import log
|
||||
from ragnar.api import Api
|
||||
from ragnar.cache import method_cache
|
||||
from ragnar.victoria import vic
|
||||
|
||||
|
||||
class Bot:
|
||||
@ -55,7 +56,7 @@ class Bot:
|
||||
self.api = Api(username=self.username, password=self.password)
|
||||
|
||||
def rsleepii(self):
|
||||
time.sleep(random.randint(10, 60))
|
||||
time.sleep(random.randint(1, 2))
|
||||
|
||||
@method_cache
|
||||
def login(self):
|
||||
@ -172,5 +173,6 @@ class Bot:
|
||||
self.rant_history.append(rant["id"])
|
||||
|
||||
def down_vote_rant(self, rant):
|
||||
log.warning("Downvoting rant by {}.".format(rant["user_username"]))
|
||||
vic.dr_downvote_rant(rant["id"],5)
|
||||
log.warning("Downvoting rant by {} for 5 times.".format(rant["user_username"]))
|
||||
log.debug("Vote result: ".format(self.api.post_rant_vote(rant["id"], -1)))
|
||||
|
@ -4,7 +4,7 @@ from concurrent.futures import ThreadPoolExecutor as Executor
|
||||
from ragnar import log
|
||||
from ragnar.bot import Bot
|
||||
from ragnar.victoria import vic
|
||||
|
||||
import time
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description="Process username and password.")
|
||||
@ -15,26 +15,24 @@ def parse_args():
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def bot_task(username, password):
|
||||
log.info(f"Created new bot runniner. Username: {username}")
|
||||
while True:
|
||||
try:
|
||||
bot = Bot(username=username, password=password)
|
||||
bot.login()
|
||||
bot.fight()
|
||||
except Exception as ex:
|
||||
log.critical(ex, exc_info=True)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
usernames = vic.get_friends()
|
||||
|
||||
with Executor(len(usernames)) as executor:
|
||||
while True:
|
||||
for username in usernames:
|
||||
executor.submit(bot_task, f"{username}@molodetz.nl", args.password)
|
||||
executor.shutdown(wait=True)
|
||||
|
||||
time_start = time.time()
|
||||
try:
|
||||
log.info(f"Created new bot runner. Username: {username}")
|
||||
bot = Bot(username=username, password=args.password)
|
||||
bot.login()
|
||||
bot.fight()
|
||||
except Exception as ex:
|
||||
log.critical(ex, exc_info=True)
|
||||
time.sleep(1)
|
||||
time_duration = time.time() - time_start
|
||||
log.info(f"Bot {username} finished in {time_duration} seconds.")
|
||||
|
||||
def run():
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user