PPF Home
Plugins
Developers
   Font size:      

Calc (v1.1)

PDF
PDF

Description

The Calc plugin lets users evaluate(calculate) mathematical expressions on IRC.

This plugin lets you give the bot a mathematical expression, e.g. 25+13*7, and it will evaluate it and tell you the result. Additionally, it can tell you the factors of a given number, and generate random numbers.

This implementation uses JEP version 2.3.0.

Configuration

The configuration file for this plugin is system/Calc/CalcConfig.xml

commandCalc

The command to perform a calculation. You can set the authLevel to control who is allowed to access the command. The output is used to define where the output from the command will go.

  • authLevel - ANY, ADMIN, MASTER, TRUSTED, NONE
  • output - CHANNEL, PM, NOTICE

      <commandCalc authLevel="none" output="channel">!calc</commandCalc>

    

commandCalcHelp

The command to get a list of functions, operators, etc that the Calc command knows. You can set the authLevel to control who is allowed to access the command. The output is used to define where the output from the command will go.

  • authLevel - ANY, ADMIN, MASTER, TRUSTED, NONE
  • output - CHANNEL, PM, NOTICE

      <commandCalcHelp authLevel="none" output="channel">!calc-help</commandCalcHelp>

    

commandFactors

The command to get the factors of the given number. You can set the authLevel to control who is allowed to access the command. The output is used to define where the output from the command will go.

  • authLevel - ANY, ADMIN, MASTER, TRUSTED, NONE
  • output - CHANNEL, PM, NOTICE

      <commandFactors authLevel="none" output="channel">!factors</commandFactors>

    

commandRandom

The command to get a random number. You can set the authLevel to control who is allowed to access the command. The output is used to define where the output from the command will go. You can set the default range from which to return a number when the command is used without parameters.

  • authLevel - ANY, ADMIN, MASTER, TRUSTED, NONE
  • output - CHANNEL, PM, NOTICE
  • defaultFrom - any number
  • defaultTo - any number

      <commandRandom authLevel="none" output="channel" defaultFrom="1" defaultTo="10">!random</commandRandom>

    

Commands

Perform a calculation

Command: !calc
Description: Evaluates an expression and returns the result.
Auth Level: none
Where to give command: channel, pm
Outputs to: same as given
Example(s):

  • !calc 25+13*7

Show list of known functions, operators, etc.

Command: !calc-help
Description: Shows the list of functions, operators, etc. known by the !calc command.
Auth Level: none
Where to give command: channel, pm
Outputs to: same as given
Example(s):

  • !calc-help

Show what factors a number consists of

Command: !factors
Description: Shows what (prime) factors a number consists of.
Auth Level: none
Where to give command: channel, pm
Outputs to: same as given
Example(s):

  • !factors 660

Generate a random number

Command: !random
Description: Generates a random number in the given or default range(ranges are inclusive).
Auth Level: none
Where to give command: channel, pm
Outputs to: same as given
Example(s):

  • !random
  • !random 6
  • !random 10 20

Change History

v1.1 Rewrite by EdorFaus, with more features. (Written before seeing v1.0)
v1.0 First Version by DeadEd