W.I.P. Database support. #4

Merged
ComputerTech merged 2 commits from :master into master 2024-02-19 10:28:47 +01:00
2 changed files with 15 additions and 12 deletions
Showing only changes of commit a3312cffda - Show all commits

View file

@ -1,34 +1,37 @@
#!/usr/bin/env python3
import sys
from src.bot import Bot
def main():
if len(sys.argv) < 2:
print("Usage: python elitebot.py <config_file>")
print('Usage: python elitebot.py <config_file>')
sys.exit(1)
config_file = sys.argv[1]
try:
bot = Bot(config_file)
except FileNotFoundError as e:
print(f"Config file not found: {e}")
print(f'Config file not found: {e}')
sys.exit(1)
except Exception as e:
print(f"Error loading bot: {e}")
print(f'Error loading bot: {e}')
sys.exit(1)
try:
print("EliteBot started successfully!")
print('EliteBot started successfully!')
bot.start()
except Exception as e:
print(f"Error starting EliteBot: {e}")
print(f'Error starting EliteBot: {e}')
sys.exit(1)
if __name__ == "__main__":
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("\nEliteBot has been stopped.")
print('\nEliteBot has been stopped.')
except Exception as e:
print(f"An unexpected error occurred: {e}")
print(f'An unexpected error occurred: {e}')

View file

@ -27,7 +27,7 @@ class Plugin(PluginBase):
self.bot.ircsend(f'PART {message_parts[1]}')
self.channel_manager.remove_channel(message_parts[1])
elif message_parts[0] == "!quit":
elif message_parts[0] == '!quit':
if len(message_parts) == 0:
quit_message = 'EliteBot!'
else:
@ -37,9 +37,9 @@ class Plugin(PluginBase):
self.bot.connected = False
sys.exit()
elif message_parts[0] == "!raw":
elif message_parts[0] == '!raw':
if len(message_parts) > 1:
if message_parts[1].upper() == "PRIVMSG" and len(message_parts) > 3:
if message_parts[1].upper() == 'PRIVMSG' and len(message_parts) > 3:
raw_command = ' '.join(message_parts[1:3]) + " :" + ' '.join(message_parts[3:])
else:
raw_command = ' '.join(message_parts[1:])