Git Product home page Git Product logo

znc-counters's Introduction

ZNC Counters

A ZNC (1.6.x version) module to count things using commands. I develop this mainly for my needs but I try to make it user-friendly.

Counters

Obviously this is the main object used in this module. It can increment, decrement and reset

Commands

  • create [(--initial | -i) <initial>] [(--step | -s) <step>] [(--cooldown | -c) <cooldown>] [(--delay | -d) <delay>] [(--message | -m) "<messsage>"] <name>

    Create a counter.

  • delete <name>

    Delete a counter if it exists.

  • reset <name> [<value>]

    Reset a counter, with value if specified otherwise with initial value of counter. Variables like previous, current, minimum and maximum values will be reseted to the reset value.

  • incr <name> [<step>]

    Increment a counter by step if specified, by step value of counter otherwise.

  • decr <name> [<step>]

    Decrement a counter by step if specified, by step value of counter otherwise.

  • set <name> <property> <value>

    Set a property of counter. (possible values as property are : initial, step, cooldown, delay and message)

  • info <name>

    Show information of a counter like its properties and other values like current, previous, minimum and maximul values.

  • print <name>

    Send the message of a counter without delay.

  • list

    List all existing counters.

Listeners

It consists to use counters with a sort of alias, but it can be used by others users who are not connected to znc server.

Commands

  • createListener <name> [<nickname>] [<listener_name>]

    Create a "listener", a sort of alias for a counter that can be used by with <listener_name>.

  • deleteListener <nickname> <listener_name>

    Delete a listener if it exists.

  • listListeners

    List all existing listeners.

How to use

The <nickname> user has to send a message like <listener_name> <command> [<arg>] with <command> which can be replaced by incr, decr etc. <arg> will be the argument of <command>.

Variables and default values

Variables that can't be changed manually by user :

  • name : the name of the counter, used to identify it
  • previous_value : the value before change
  • current_value : the current value
  • minimum_value : the minimum value reached
  • maximum_value : the maximum value reached

There are some default values to create counters or listeners.

  • For counters :
    • Initial : 0
    • Step : 1
    • Cooldown : 0 (seconds)
    • Delay : 0 (seconds)
    • Message : "{NAME} has value : {CURRENT_VALUE}"
  • For Listeners :
    • Nickname : current nickname of user that create listener
    • Listener name : "!" + name of the counter

Format of message

The following keywords (case sensitive) will be replaced in the message sent by the module with the appropriate value :

  • {NAME} : the name of the counter
  • {INITIAL} : the initial value of the counter used at creation and reset
  • {STEP} : the step value used to increment and decrement the counter
  • {COOLDOWN} : the cooldown between 2 messages from the counter
  • {DELAY} : the delay between the change of value and the sending message
  • {PREVIOUS_VALUE} : the previous value to the current one
  • {CURRENT_VALUE} : the current value of the counter
  • {MINIMUM_VALUE} : the minimum value reached
  • {MAXIMUM_VALUE} : the maximum value reached

Examples

/znc *counters create test
/znc *counters incr test 2  //will send "test has value : 2"
/znc *counters set test message "{NAME} changed from {PREVIOUS_VALUE} to {CURRENT_VALUE}"
/znc *counters reset        //will send "test changed from 2 to 0"

/znc *counters createListener test user !testl
//In the above example, if the user with nick "user" sends a message beginning with "!testl" this will perform
//the rest of the message like a command.
//For example : "user" sends "!testl incr", this will execute "incr" command for the counter "test" and
//send "test changed from 0 to 1"

This module uses argparse to parse "create" command : https://github.com/hbristow/argparse

znc-counters's People

Contributors

trobiun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.