Paste #21198: Diff note for paste #21197

Date: 2015/10/18 19:17:55 UTC-07:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


 ######################################################################################################
 ######################################################################################################
 ##          _   _____    __     ___   _____                   ___                                   ##
 ##       __| |  \_   \  /__\   / __\ /__   \  __ _   __ _    / _ \  __ _  _ __  ___   ___  _ __     ##
 ##      / _` |   / /\/ / \//  / /      / /\/ / _` | / _` |  / /_)/ / _` || '__|/ __| / _ \| '__|    ##
 ##     | (_| |/\/ /_  / _  \ / /___   / /   | (_| || (_| | / ___/ | (_| || |   \__ \|  __/| |       ##
 ##      \__,_|\____/  \/ \_/ \____/   \/     \__,_| \__, | \/      \__,_||_|   |___/ \___||_|       ##
 ##                                                   |___/                                          ##
 ##   Made by Fortifier42                                                                            ##
 ######################################################################################################
 ######################################################################################################
 
 IRC_Chat:
   debug: false
   type: format
   format: "<&sp><&7>[<&a>IRC<&7>] <&3><text>"
 
 IRC_Config:
   type: yaml data
 
   # Change this to change the name your bot will display with in the IRC Channel!
   #Probably a good idea to change this so you don't get conflicts between other bots/users.
   botname: "Tag-Parser"
 
   cmds:
     # Change the following line to change the join command argument(s)!
     # At this stage, it does not change the /help irc output. :(
     join:
     - join
     - connect
     - start
 
     # Change the following line to change the quit command argument(s)!
     # At this stage, it does not change the /help irc output. :(
     quit:
     - quit
     - leave
     - exit
     - disconnect
     - stop
 
     # Change the following line to change the msg command argument(s)!
     # At this stage, it does not change the /help irc output. :(
     msg:
     - send
     - say
     - tell
     - msg
     - message
 
   # Change the following line to change the irc server to join!
   server: "irc.esper.net"
 
   # Change the following line to change the channel the bot will join!
   channel: "#denizen-dev"
 
   # Admins (Access to special commands)
   Admins:
   - Fortifier
 
   # Change the following line to change what the prefix should be for in-irc commands
   prefix: ">"
 
   # Change the in-irc commands here
   triggers:
     # To parse tags
     tag:
     - tag
     - tags
     - t
     # To check server versions
     version:
     - version
     - vers
     - ver
     - v
     # To check server RAM
     memory:
     - memory
     - mem
     - ram
     # Get help!
     help:
     - help
     - h
     # Check server TPS
     tps:
     - timings
     - timing
     - tps
     - lag
     # Check number of tags parsed
     count:
     - parsed
     - count
     - total
     # Reload Denizen scripts
     reload:
     - reloadscripts
     - reload
     - scripts
     # Restart the server
     restart:
     - restart
     # Execute a server command
     execute:
     - command
     - cmd
     - execute
     - ex
 
   # Set this to "" to stop logging all together, or change the file which IRC actions will be logged to.
   # Currently only /irc send <message> and tag parsing are logged.
   # This is from the server's base directory
   logfile: plugins/Denizen/logs/ircbot.log
 
 IRC_Command:
   debug: false
   type: command
   name: irc
   usage: /irc <&lt>(join/quit/msg <&lt>message<&gt>)<&gt>
   permission: irc.admin
   description: Used to connect, leave and send messages to IRC.
   script:
     - if <context.args.size> == 0 {
       - narrate format:IRC_Chat "<&c><script.yaml_key[usage]>"
       - queue clear
     }
     - define cmd <context.args.get[1]>
     - if <context.args.size> == 1 {
       - if <s@IRC_Config.yaml_key[cmds.join].contains[<def[cmd]>]> {
         - ~irc connect ircserver@<s@IRC_Config.yaml_key[server]>
         - irc raw ircserver@<s@IRC_Config.yaml_key[server]> "USER <s@IRC_Config.yaml_key[botname]> <s@IRC_Config.yaml_key[botname]>_ <s@IRC_Config.yaml_key[botname]>__ <s@IRC_Config.yaml_key[botname]>"
         - irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NICK <s@IRC_Config.yaml_key[botname]>"
         - irc join ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>
         - narrate format:IRC_Chat "Joined the IRC."
         - queue clear
       }
       else if <s@IRC_Config.yaml_key[cmds.quit].contains[<def[cmd]>]> {
         - ~irc leave ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>
         - ~irc quit ircserver@<s@IRC_Config.yaml_key[server]>
         - narrate format:IRC_Chat "Left the IRC."
         - queue clear
       }
       else {
         - narrate format:IRC_Chat "<&c>Invalid command!"
         - queue clear
       }
     }
     else {
       - if <s@IRC_Config.yaml_key[cmds.msg].contains[<def[cmd]>]> {
         - define msg "<context.args.get[2].to[<context.args.size>].space_separated||null>"
         - if <def[msg]> == null {
           - narrate format:IRC_Chat "<&c>No message has been specified."
           - queue clear
         }
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> <def[msg]>
         - narrate format:IRC_Chat "Sent message: <&f><&sq><def[msg]><&sq>"
         - if <s@IRC_Config.yaml_key[logfile]> == "" queue clear
         - log "<player.name||Console> sent <&sq><def[msg]><&sq>" file:<s@IRC_Config.yaml_key[logfile]>
       }
     }
 
 IRC_Parsing:
   debug: false
   type: world
   events:
     on irc message:
       - if <context.channel> != "ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>" || <context.message.starts_with[<s@IRC_Config.yaml_key[prefix]>].not> {
         - queue clear
       }
       - define Msg <context.message.after[<s@IRC_Config.yaml_key[prefix]>].escaped.trim>
       - define Args <def[Msg].split[<&sp>]>
       - define Cmd <def[Args].get[1]||null>
       - if <def[Cmd]> == null || <def[Cmd]> == "" {
         - queue clear
       }
       - define Admin <s@IRC_Config.yaml_key[admins].contains[<context.speaker>]>
 
 
       ## Tag Parse section
       - if <s@IRC_Config.yaml_key[triggers.tag].contains[<def[Cmd]>]> {
         - define tags <def[Msg].after[<def[Cmd]>].unescaped>
         - if <def[tags]> == "" queue clear
         - define parsed "<parse.substring[1,300]:<def[tags]>>"
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&r><&co> the tag <&sq><&b><def[tags]><&r><&sq> fills with <&sq><&b><def[parsed]><&r><&sq>"
         - if <s@IRC_Config.yaml_key[logfile]> == "" queue clear
         - log "<context.speaker> parsed <def[tags]>" file:<s@IRC_Config.yaml_key[logfile]>
         - flag server ParseCount:++
       }
 
 
       ## Version Checking section
       else if <s@IRC_Config.yaml_key[triggers.version].contains[<def[Cmd]>]> {
         - define Choice <def[Msg].after[<def[Cmd]>].trim>
         - if <def[Choice]> == "denizen" || <def[Choice]> == "" {
             - define Version "Denizen Version '<&b><server.denizen_version><&9>'"
           }
           else if <def[Choice]> == "spigot" {
             - define Version "Spigot Version '<&b><server.version><&9>'"
           }
           else if <def[Choice]> == "bukkit" {
             - define Version "Bukkit Version '<&b><server.bukkit_version><&9>'"
           }
           else {
             - define Plugin <server.list_plugins.filter[name.starts_with[<def[Choice]>]].get[1]||null>
             - if <def[plugin]> == null {
               - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&c><&co> this server is not running that plugin!"
               - queue clear
             }
             - define Version "<def[Plugin].name> Version '<&b><def[Plugin].version><&9>'"
           }
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&co> <&9>this server is running <def[Version]>."
       }
 
 
       ## Memory Checking section
       else if <s@IRC_Config.yaml_key[triggers.memory].contains[<def[Args].get[1]>]> {
         - define Used <server.ram_allocated.sub[<server.ram_free>].div[1048576].round>
         - define Total <server.ram_max.div[1048576]>
         - define Usage "<&a><def[Used]><&9>/<&a><def[Total]><&9>MB"
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&9><&co> The server is currently using <def[Usage]> RAM."
       }
 
 
       ## TPS Checking section
       else if <s@IRC_Config.yaml_key[triggers.tps].contains[<def[Args].get[1]>]> {
         - define TPS <server.recent_tps.parse[round_to[2]]>
         - define TPS "<&r>1m ago - <def[TPS].get[1]><&9>, <&r> 5m ago - <def[TPS].get[2]><&9>, <&r> 15m ago - <def[TPS].get[3]><&9>"
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&9><&co> The 3 most recent TPS values are: <def[TPS]>"
       }
 
 
       ## Parse Count section
       else if <s@IRC_Config.yaml_key[triggers.count].contains[<def[Cmd]>]> {
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&9><&co> I have parsed a total of <&r><server.flag[ParseCount].as_int||0><&9> tags!"
       }
 
 
       ## Help section
       else if <s@IRC_Config.yaml_key[triggers.help].contains[<def[Args].get[1]>]> {
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>Hi <&1><context.speaker><&4> I am a Denizen Tag-Parsing bot, developed by <&1>Fortifier42<&4> of <&1>http://www.theausfort.net/<&4>."
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>I have a number of commands available for you to use which all start with '<&1><s@IRC_Config.yaml_key[prefix]><&4>'"
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To parse a tag, use the commands <&1><s@IRC_Config.yaml_key[triggers.tag].separated_by[<&4> or <&1>]><&4> <&lt>tags<&gt>."
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To check a plugin or server version, use the commands <&1><s@IRC_Config.yaml_key[triggers.version].separated_by[<&4> or <&1>]><&4> followed by the name of the plugin or service."
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To check the server's current RAM usage, use the commands <&1><s@IRC_Config.yaml_key[triggers.memory].separated_by[<&4> or <&1>]><&4>."
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To see how many tags I have parsed, use the commands <&1><s@IRC_Config.yaml_key[triggers.count].separated_by[<&4> or <&1>]><&4>."
         - if <def[Admin]> {
           - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To execute a command on the server use the commands <&1><s@IRC_Config.yaml_key[triggers.execute].separated_by[<&4> or <&1>]> <&lt>command (arguments)<&gt><&4>."
           - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To restart the server use the commands <&1><s@IRC_Config.yaml_key[triggers.restart].separated_by[<&4> or <&1>]><&4>."
           - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To reload the Denizen scripts running on the server use the commands <&1><s@IRC_Config.yaml_key[triggers.restart].separated_by[<&4> or <&1>]><&4>."
         }
         - ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&4>To access this help again, use the commands <&1><s@IRC_Config.yaml_key[triggers.help].separated_by[<&4> or <&1>]><&4>."
       }
 
 
       ### ADMIN COMMANDS ###
       ## Restart Server
       else if <s@IRC_Config.yaml_key[triggers.restart].contains[<def[Cmd]>]> && <def[Admin]> {
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&c><&co> Restarting Server. Expect reconnection in ~ 1 Minute."
         - wait 2s
         - execute as_server "restart"
       }
 
 
       ## Reload Scripts
       else if <s@IRC_Config.yaml_key[triggers.reload].contains[<def[Cmd]>]> && <def[Admin]> {
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&c><&co> Reloading Scripts."
         - flag global Reloading
         - execute as_server "denizen reload scripts"
         #- ~irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NOTICE <context.speaker> :<&c>Reloaded Scripts."
       }
 
 
       ## Execute Command
       else if <s@IRC_Config.yaml_key[triggers.execute].contains[<def[Cmd]>]> && <def[Admin]> {
         - define Cmd <def[Msg].after[<def[Cmd]>]>
         - if <def[Cmd].contains_any[stop|restart|irc]> {
           - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&c><&co> This command is prohibited!"
           - queue clear
         }
         - execute as_server <def[Cmd].unescaped> silent save:Cmd
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&9><&co> Command executed!"
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&9><&co> Output<&co> <&c><entry[Cmd].output.space_separated>"
       }
 
     on reload scripts:
       - if <server.has_flag[Reloading].not> queue clear
       - if <context.haderror> {
         - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<&c>Error while reloading scripts!"
       }
       - flag global Reloading:!