60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
|
"""
|
||
|
This module sends samefag votes to akun.
|
||
|
Be discreet about it.
|
||
|
"""
|
||
|
|
||
|
import time
|
||
|
from http_request_randomizer.requests.proxy.requestProxy import RequestProxy
|
||
|
|
||
|
VOTE_URL = 'https://fiction.live/api/anonkun/voteChapter'
|
||
|
|
||
|
def vote(poll_id, vote_id, numvotes, timeout):
|
||
|
"""
|
||
|
Takes in vote identifiers and sends the
|
||
|
specified number of votes through random proxies.
|
||
|
Timeout is in seconds.
|
||
|
Returns a string message.
|
||
|
"""
|
||
|
start_time = time.time()
|
||
|
req_proxy = RequestProxy()
|
||
|
payload = {
|
||
|
'_id': poll_id,
|
||
|
'vote': vote_id
|
||
|
}
|
||
|
i = 0
|
||
|
while i < numvotes:
|
||
|
request = req_proxy.generate_proxied_request(VOTE_URL, method = 'POST', data = payload, req_timeout=20)
|
||
|
if request is not None and request.status_code == 200:
|
||
|
i += 1
|
||
|
request = None
|
||
|
if time.time() - start_time > timeout:
|
||
|
return "Voting timed out, " + str(i) + " votes successfully cast"
|
||
|
return str(i) + " votes successfully cast"
|
||
|
|
||
|
@thread
|
||
|
@commands('samefag')
|
||
|
@example('.samefag poll_id option_id numvotes')
|
||
|
@example('Illustrated guide: https://i.imgur.com/fhFI2yi.png')
|
||
|
@example('.samefag hRChW6prwF7v7sNi5 21 2')
|
||
|
def samefag(bot, trigger):
|
||
|
"""
|
||
|
Samefags votes.
|
||
|
"""
|
||
|
max_queries = bot.config.samefag.max_queries
|
||
|
timeout = bot.config.samefag.timeout
|
||
|
if not max_queries or not timeout:
|
||
|
return bot.reply("Module not configured")
|
||
|
max_queries = int(max_queries)
|
||
|
timeout = int(timeout)
|
||
|
|
||
|
poll_id = trigger.group(2)
|
||
|
vote_id = trigger.group(3)
|
||
|
numvotes = trigger.group(4)
|
||
|
try:
|
||
|
numvotes = int(numvotes)
|
||
|
except TypeError:
|
||
|
return bot.reply("Invalid parameters")
|
||
|
numvotes = min(numvotes, max_queries)
|
||
|
bot.reply("Casting votes...")
|
||
|
bot.reply(vote(poll_id, vote_id, numvotes, timeout))
|