Script expected to send all commands to Twitch chat in random order and within specified time period then loop indefinitely, but despite showing success in command window, it actually sends only the first message in Twitch chat. This code is not my, and I’m in no way a programmer or scripter, nevertheless I’ve killed a whole day to study all this mumbo-jumbo, so I can understand your nerdish answer pretty decently. Don’t punch in the face, though. =^_^=
#!/usr/bin/env python
from time import sleep
from random import randint, shuffle
from sys import argv
from twitchio.ext import commands
import logging
logging.basicConfig(format='%(asctime)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO)
class Bot(commands.Bot):
def __init__(self):
super().__init__(
token=argv[1],
prefix='',
initial_channels=['#channel_name']
)
async def event_ready(self):
lst = ['command_1', 'command_2', 'command_3']
while True:
shuffle(lst)
for x in lst:
logging.info(f'{self.nick} is sending: {x}')
await bot.connected_channels[0].send(x)
sleep(randint(210,270))
logging.info('Sent all msgs, sleeping...')
sleep(randint(270,300))
logging.info(f'Slept!\n')
bot = Bot()
bot.run()
Sending all three messages Recieving only one message
I'd like to receive all three of my sexy commands in Twitch chat after sending them. And indefinite loop afterwords would be pretty awesome too. Thanks for your time and sorry for my lame English (not a native speaker). Cheers!