Lots of scripting updates

add_scripting
silverwizard 2 years ago
parent 36843ddd61
commit bf5c8b095f
  1. BIN
      __pycache__/burningdice.cpython-38.pyc
  2. 122
      burningdice.py
  3. 5
      help.html
  4. 13
      metadata.ini

@ -2,11 +2,11 @@ from JJMumbleBot.lib.plugin_template import PluginBase
from JJMumbleBot.lib.utils.plugin_utils import PluginUtilityService
from JJMumbleBot.lib.utils.logging_utils import log
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.lib.resources.strings import *
import os
import random
import sqlite3
class Plugin(PluginBase):
@ -16,6 +16,13 @@ class Plugin(PluginBase):
self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
self.metadata = PluginUtilityService.process_metadata(f'plugins/extensions/{self.plugin_name}')
self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
init_db = sqlite3.connect('init.db')
init = init_db.cursor()
init.execute("CREATE TABLE IF NOT EXISTS v1 (content string, name string UNIQUE)")
init.execute("CREATE TABLE IF NOT EXISTS v2 (content string, name string UNIQUE)")
init.execute("CREATE TABLE IF NOT EXISTS v3 (content string, name string UNIQUE)")
init_db.commit()
init_db.close()
self.is_running = True
log(
INFO,
@ -33,6 +40,7 @@ class Plugin(PluginBase):
print_mode=PrintMode.REG_PRINT.value
)
def stop(self):
if self.is_running:
self.quit()
@ -41,6 +49,110 @@ class Plugin(PluginBase):
if not self.is_running:
self.__init__()
def cmd_volley(self, data):
all_data = data.message.strip().split()
try:
v = int(all_data[1])
if (v == 1):
volley = "v1"
elif (v == 2):
volley = "v2"
elif (v == 3):
volley = "v3"
else:
gs.gui_service.quick_gui("Format: !volley # script actions",
text_type='header', box_align='left')
return
script = str(all_data[2:])
init_db = sqlite3.connect('init.db')
cur = init_db.cursor()
cur.execute("INSERT INTO " + volley + " values (?,?) ON CONFLICT(name) DO UPDATE SET content=\"" + script + "\"", (str(script),str(gs.mumble_inst.users[data.actor]['name'])))
init_db.commit()
init_db.close()
gs.gui_service.quick_gui(str(gs.mumble_inst.users[data.actor]['name']) + " has scripted volley " + str(v), text_type='header', box_align='left')
return
except IndexError:
gs.gui_service.quick_gui("Format: !volley # script actions",
text_type='header', box_align='left')
return
def reveal_actions(self,volleynum):
volley = "v" + str(volleynum)
init_db = sqlite3.connect('init.db')
cur = init_db.cursor()
cur.execute("SELECT * from " + volley + " ORDER BY name DESC")
ret_text = "Volley " + str(volleynum) + "<br>"
for row in cur:
ret_text += str(row[1]) + ": " + row[0] + "<br>"
init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
def cmd_revealv1(self, data):
self.reveal_actions(1)
return
def cmd_revealv2(self, data):
self.reveal_actions(2)
return
def cmd_revealv3(self, data):
self.reveal_actions(3)
return
def whoscript(self,volleynum):
volley = "v" + str(volleynum)
init_db = sqlite3.connect('init.db')
cur = init_db.cursor()
cur.execute("SELECT * from " + volley + " ORDER BY name DESC")
ret_text = "Volley " + str(volleynum) + "<br>"
for row in cur:
ret_text += str(row[1]) + "<br>"
init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
def cmd_scriptedv1(self, data):
self.whoscript(1)
return
def cmd_scriptedv2(self, data):
self.whoscript(2)
return
def cmd_scriptedv3(self, data):
self.whoscript(3)
return
def cmd_scripted(self, data):
self.whoscript(1)
self.whoscript(2)
self.whoscript(3)
return
def clear_volley(self, volleynum):
volley = "v" + str(volleynum)
init_db = sqlite3.connect('init.db')
init = init_db.cursor()
init.execute("DROP TABLE " + volley)
init_db.commit()
init.execute("CREATE TABLE IF NOT EXISTS " + volley + " (content string, name string UNIQUE)")
init_db.commit()
init_db.close()
gs.gui_service.quick_gui("Purged all for " + volley, text_type='header', box_align='left')
def cmd_clearv1(self, data):
self.clear_volley(1)
return
def cmd_clearv2(self, data):
self.clear_volley(2)
return
def cmd_clearv3(self, data):
self.clear_volley(3)
return
def cmd_bw(self, data):
all_data = data.message.strip().split()
try:
@ -112,9 +224,7 @@ class Plugin(PluginBase):
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
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(CMD_INVALID_CUSTOM_ROLL,
gs.gui_service.quick_gui("Format: !bw # [a][a]",
text_type='header', box_align='left')
return
@ -194,9 +304,7 @@ class Plugin(PluginBase):
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
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(CMD_INVALID_CUSTOM_ROLL,
gs.gui_service.quick_gui("!bwo # [a][a]",
text_type='header', box_align='left')
return

@ -7,3 +7,8 @@ All commands can be run by typing it in the chat or privately messaging JJMumble
<b>!touchofages</b>: Print the table of touch of ages difficulties.<br>
<b>!aurareading</b>: Print the table of aura reading difficulties.<br>
<b>!sessionend</b>: Print the Artha awards table.<br>
<b>!volley</b>: Sample !volley 1 Block Strike. Prepend the volley number and then the actions. Everything after the volley number is freeform.<br>
<b>!revealv[1-3]</b>: Prints everyone's script for given volley.<br>
<b>!clearv[1-3]</b>: Clears all scripts for given volley.<br>
<b>!scriptedv[1-3]</b>: Lists who has scripted for given volley.<br>
<b>!scripted</b>: Lists who has scripted for all volleys.<br>

@ -11,7 +11,18 @@ PluginCommands: [
"touchofages",
"aurareading",
"sessionend",
"bwo"
"bwo",
"volley",
"revealv1",
"revealv2",
"revealv3",
"clearv1",
"clearv2",
"clearv3",
"scriptedv1",
"scriptedv2",
"scriptedv3",
"scripted"
]
[Plugin Settings]

Loading…
Cancel
Save