From e94955f4688451a9b0b5a90b93981a3eea64378e Mon Sep 17 00:00:00 2001 From: Stef Dunlap Date: Fri, 3 Mar 2023 21:52:17 -0500 Subject: [PATCH] Add opts --- .gitignore | 2 +- actors.py => playbot.py | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) rename actors.py => playbot.py (73%) diff --git a/.gitignore b/.gitignore index 5ceb386..0a764a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -venv +env diff --git a/actors.py b/playbot.py similarity index 73% rename from actors.py rename to playbot.py index a2f40b1..8667568 100644 --- a/actors.py +++ b/playbot.py @@ -1,3 +1,4 @@ +import argparse import irc.bot import time import re @@ -47,12 +48,22 @@ class PlayBot(irc.bot.SingleServerIRCBot): # Set the bot's nickname back to its original nickname connection.nick(self._nickname) + + if __name__ == "__main__": - channel = "#playhouse" - nickname = "PlayBot" - server = "localhost" - port = 6667 - play_file = "play.txt" + parser = argparse.ArgumentParser(description='PlayBot - an IRC bot for performing plays') + parser.add_argument('-c', '--channel', default='#playhouse', help='the IRC channel to join') + parser.add_argument('-n', '--nickname', default='PlayBot', help='the nickname for the bot') + parser.add_argument('-s', '--server', default='localhost', help='the IRC server to connect to') + parser.add_argument('-p', '--port', default='6667', help='the port to connect to on the IRC server') + parser.add_argument('-f', '--file', default="play.txt", dest='play_file', help='the file containing the play script') + args = parser.parse_args() + + channel = args.channel + nickname = args.nickname + server = args.server + port = int(args.port) + play_file = args.play_file + bot = PlayBot(channel, nickname, server, port, play_file) bot.start() -