mirror of
https://github.com/Xevion/unbelievaselfbot.git
synced 2025-12-06 05:16:57 -06:00
custom argparse based client launching, token.dat token storage
This commit is contained in:
58
main.py
58
main.py
@@ -1,46 +1,22 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import time
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
import discord
|
||||
from bot.client import UnbelievaClient
|
||||
|
||||
client = discord.Client()
|
||||
channel_id = 788214285712359475
|
||||
logging.basicConfig(format='[%(asctime)s] [%(levelname)s] [%(funcName)s] %(message)s')
|
||||
logger = logging.getLogger(__file__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
last_message = time.time() - 5
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Start the discord bot.')
|
||||
parser.add_argument('channel', metavar='CHANNEL', type=int,
|
||||
help='The channel ID for the bot to target.')
|
||||
parser.add_argument('bot', metavar='BOT', type=int, help='The ID of the UnbelievaBoat bot to target.')
|
||||
|
||||
# tasks = {
|
||||
# '$task': {
|
||||
# 'duration': 13 * 60 + 5,
|
||||
# 'last':
|
||||
# }
|
||||
# }
|
||||
parsed = parser.parse_args()
|
||||
client = UnbelievaClient(parsed.bot, parsed.channel)
|
||||
|
||||
|
||||
async def income_task(task: str, minutes: int):
|
||||
global last_message
|
||||
await client.wait_until_ready()
|
||||
channel = client.get_channel(channel_id)
|
||||
while not client.is_closed():
|
||||
# Sleep between commands
|
||||
wait_time = 7 - (time.time() - last_message)
|
||||
last_message = time.time()
|
||||
await asyncio.sleep(max(0.0, wait_time))
|
||||
|
||||
await channel.send(task)
|
||||
await asyncio.sleep((minutes * 60) + 5)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print('Logged in as')
|
||||
print(client.user.name)
|
||||
print(client.user.id)
|
||||
print('------')
|
||||
|
||||
|
||||
client.loop.create_task(income_task('$work', 5))
|
||||
client.loop.create_task(income_task('$crime', 20))
|
||||
client.loop.create_task(income_task('$slut', 13))
|
||||
|
||||
client.run(sys.argv[1], bot=False)
|
||||
logger.info('Starting bot.')
|
||||
with open('../token.dat', 'r') as file:
|
||||
token = file.read()
|
||||
client.run(token, bot=False)
|
||||
|
||||
Reference in New Issue
Block a user