Fixed error messages

main
silverwizard 3 years ago
parent 69318abf6c
commit 834d89bbba
  1. BIN
      __pycache__/shadowdice.cpython-38.pyc
  2. 2
      aliases.csv
  3. 1
      metadata.ini
  4. 51
      shadowdice.py

@ -4,3 +4,5 @@ pass,(initpass)
listinits,(listinit) listinits,(listinit)
removeinit,(delinit) removeinit,(delinit)
rollinits,(rollinit) rollinits,(rollinit)
srun4,(srun)
srun5,(srun)

1 alias command
4 listinits (listinit)
5 removeinit (delinit)
6 rollinits (rollinit)
7 srun4 (srun)
8 srun5 (srun)

@ -18,6 +18,7 @@ PluginCommands: [
"delivery", "delivery",
"perception_mods", "perception_mods",
"environmental", "environmental",
"hosts",
"concealability" "concealability"
] ]

@ -2,7 +2,6 @@ from JJMumbleBot.lib.plugin_template import PluginBase
from JJMumbleBot.lib.utils.plugin_utils import PluginUtilityService from JJMumbleBot.lib.utils.plugin_utils import PluginUtilityService
from JJMumbleBot.lib.utils.logging_utils import log from JJMumbleBot.lib.utils.logging_utils import log
from JJMumbleBot.lib.utils.print_utils import PrintMode from JJMumbleBot.lib.utils.print_utils import PrintMode
from JJMumbleBot.plugins.extensions.randomizer.resources.strings import CMD_INVALID_CUSTOM_ROLL
from JJMumbleBot.settings import global_settings as gs from JJMumbleBot.settings import global_settings as gs
from JJMumbleBot.lib.resources.strings import * from JJMumbleBot.lib.resources.strings import *
import os import os
@ -19,7 +18,7 @@ class Plugin(PluginBase):
self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS)) self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
init_db = sqlite3.connect('init.db') init_db = sqlite3.connect('init.db')
init = init_db.cursor() init = init_db.cursor()
init.execute("CREATE TABLE inits (dice int, bonus int, total int, name string UNIQUE)") init.execute("CREATE TABLE IF NOT EXISTS inits (dice int, bonus int, total int, name string UNIQUE)")
init_db.commit() init_db.commit()
init_db.close() init_db.close()
self.is_running = True self.is_running = True
@ -65,9 +64,7 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
gs.gui_service.quick_gui("Added init for: " + character_name, text_type='header', box_align='left') gs.gui_service.quick_gui("Added init for: " + character_name, text_type='header', box_align='left')
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !addinit #dice #bonus $name",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -82,9 +79,7 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !listinit",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -99,9 +94,7 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !listinitpools",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -122,9 +115,7 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !initpass",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -146,8 +137,6 @@ class Plugin(PluginBase):
init_db.commit() init_db.commit()
init_db.close() init_db.close()
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL,
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui("Can only subtract init from a name in the list of inits, try !listinit to confirm spellings", gs.gui_service.quick_gui("Can only subtract init from a name in the list of inits, try !listinit to confirm spellings",
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -164,8 +153,6 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
gs.gui_service.quick_gui("Deleted init for: " + name + " (if they exist)", text_type='header', box_align='left') gs.gui_service.quick_gui("Deleted init for: " + name + " (if they exist)", text_type='header', box_align='left')
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL,
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui("Can only remove init from a name in the list of inits, try !listinit to confirm spellings", gs.gui_service.quick_gui("Can only remove init from a name in the list of inits, try !listinit to confirm spellings",
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -206,9 +193,7 @@ class Plugin(PluginBase):
init_db.close() init_db.close()
return return
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !rollinit",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -222,7 +207,10 @@ class Plugin(PluginBase):
for i in range(number_of_dice): for i in range(number_of_dice):
random.seed(int.from_bytes(os.urandom(8), byteorder="big")) random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
this_die = random.randint(1,6) this_die = random.randint(1,6)
ret_text += f"{this_die}, " if i == 0:
ret_text += f"{this_die}"
else:
ret_text += f", {this_die}"
if this_die > 4: if this_die > 4:
successes = successes + 1 successes = successes + 1
if this_die == 1: if this_die == 1:
@ -231,9 +219,7 @@ class Plugin(PluginBase):
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return return
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !srun #",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -249,7 +235,10 @@ class Plugin(PluginBase):
while i < number_of_dice: while i < number_of_dice:
random.seed(int.from_bytes(os.urandom(8), byteorder="big")) random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
this_die = random.randint(1,6) this_die = random.randint(1,6)
ret_text += f"{this_die}, " if i == 0:
ret_text += f"{this_die}"
else:
ret_text += f", {this_die}"
if this_die > 4: if this_die > 4:
successes = successes + 1 successes = successes + 1
if this_die == 1: if this_die == 1:
@ -257,14 +246,14 @@ class Plugin(PluginBase):
if this_die == 6: if this_die == 6:
i = i-1 i = i-1
explosions = explosions + 1 explosions = explosions + 1
if i < 1:
ret_text +=f", "
i = i + 1 i = i + 1
ret_text += f"<br>Successes: {successes} , Ones: {ones} , Explosions: {explosions}" ret_text += f"<br>Successes: {successes} , Ones: {ones} , Explosions: {explosions}"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return return
except IndexError: except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL, gs.gui_service.quick_gui("Format: !preedge #",
origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value)
gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL,
text_type='header', box_align='left') text_type='header', box_align='left')
return return
@ -287,3 +276,7 @@ class Plugin(PluginBase):
def cmd_environmental(self, data): def cmd_environmental(self, data):
ret_text = "<table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:gold;\">ENVIRONMENTAL </caption> <tbody><tr> <th style=\"background:black;color:gold;\">VISIBILITY </th> <th style=\"background:black;color:gold;\">LIGHT / GLARE </th> <th style=\"background:black;color:gold;\">WIND </th> <th style=\"background:black;color:gold;\">RANGE </th> <th style=\"background:black;color:gold;\">MODIFIER </th></tr> <tr> <td>Clear</td> <td>Full Light / No Glare</td> <td>None / Light Breeze</td> <td>Short</td> <td>0 </td></tr> <tr> <td>Light Rain / Fog / Smoke</td> <td>Partial Light / Weak Glare</td> <td>Light Winds / Light Breeze</td> <td>Medium</td> <td>-1 </td></tr> <tr> <td>Moderate Rain / Fog / Smoke</td> <td>Dim Light / Moderate Glare</td> <td>Moderate Winds / Light Breeze</td> <td>Long</td> <td>-3 </td></tr> <tr> <td>Heavy Rain / Fog / Smoke</td> <td>Total Darkness/ Blinding Glare</td> <td>Strong Winds / Light Breeze</td> <td>Extreme</td> <td>-6 </td></tr> <tr> <td>Combination of two or more conditions at the -6 level row</td> <td></td> <td></td> <td></td> <td>-10 </td></tr></tbody></table>" ret_text = "<table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:gold;\">ENVIRONMENTAL </caption> <tbody><tr> <th style=\"background:black;color:gold;\">VISIBILITY </th> <th style=\"background:black;color:gold;\">LIGHT / GLARE </th> <th style=\"background:black;color:gold;\">WIND </th> <th style=\"background:black;color:gold;\">RANGE </th> <th style=\"background:black;color:gold;\">MODIFIER </th></tr> <tr> <td>Clear</td> <td>Full Light / No Glare</td> <td>None / Light Breeze</td> <td>Short</td> <td>0 </td></tr> <tr> <td>Light Rain / Fog / Smoke</td> <td>Partial Light / Weak Glare</td> <td>Light Winds / Light Breeze</td> <td>Medium</td> <td>-1 </td></tr> <tr> <td>Moderate Rain / Fog / Smoke</td> <td>Dim Light / Moderate Glare</td> <td>Moderate Winds / Light Breeze</td> <td>Long</td> <td>-3 </td></tr> <tr> <td>Heavy Rain / Fog / Smoke</td> <td>Total Darkness/ Blinding Glare</td> <td>Strong Winds / Light Breeze</td> <td>Extreme</td> <td>-6 </td></tr> <tr> <td>Combination of two or more conditions at the -6 level row</td> <td></td> <td></td> <td></td> <td>-10 </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center') gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_hosts(self, data):
ret_text = "<table border=\"1\" style=\"text-align:center;background:black;color:white;\"><caption style=\"color:gold;\">SAMPLE HOST RATINGS</caption><tbody><tr><th style=\"background:black;color:gold;\">EXAMPLES</th><th style=\"background:black;color:gold;\">RATING</th></tr><tr><td>Personal sites, pirate archives, public education</td><td>1-2</td></tr><tr><td>Low-end commercial, private business, public libraries, small policlubs</td><td>3-4</td></tr><tr><td>Social media, small colleges and universities, local police, international policlubs</td><td>5-6</td></tr><tr><td>Matrix games, local corporate hosts, large universities, low-level government</td><td>7-8</td></tr><tr><td>Affluent groups, regional corporate hosts, major government, secure sites</td><td>9-10</td></tr><tr><td>Megacorporate headquarters, military command, clandestine head office</td><td>11-12</td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')

Loading…
Cancel
Save