@ -2,11 +2,11 @@ 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
import random
import random
import sqlite3
class Plugin ( PluginBase ) :
class Plugin ( PluginBase ) :
@ -16,6 +16,13 @@ class Plugin(PluginBase):
self . plugin_name = os . path . basename ( __file__ ) . rsplit ( ' . ' ) [ 0 ]
self . plugin_name = os . path . basename ( __file__ ) . rsplit ( ' . ' ) [ 0 ]
self . metadata = PluginUtilityService . process_metadata ( f ' plugins/extensions/ { self . plugin_name } ' )
self . metadata = PluginUtilityService . process_metadata ( f ' plugins/extensions/ { self . plugin_name } ' )
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 = 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
self . is_running = True
log (
log (
INFO ,
INFO ,
@ -33,6 +40,7 @@ class Plugin(PluginBase):
print_mode = PrintMode . REG_PRINT . value
print_mode = PrintMode . REG_PRINT . value
)
)
def stop ( self ) :
def stop ( self ) :
if self . is_running :
if self . is_running :
self . quit ( )
self . quit ( )
@ -41,6 +49,110 @@ class Plugin(PluginBase):
if not self . is_running :
if not self . is_running :
self . __init__ ( )
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 ) :
def cmd_bw ( self , data ) :
all_data = data . message . strip ( ) . split ( )
all_data = data . message . strip ( ) . split ( )
try :
try :
@ -112,9 +224,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: !bw # [a][a] " ,
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
@ -194,9 +304,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 ( " !bwo # [a][a] " ,
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