DokuWiki

It's better when it's simple

User Tools

Site Tools


teams:dokubot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
teams:dokubot [2013-08-03 23:55] 2001:4dd0:ff00:809d:76e5:bff:fedb:c1b4teams:dokubot [2015-05-21 02:36] – [Usage] andrwe
Line 1: Line 1:
 ====== DokuBot ====== ====== DokuBot ======
 +
 +===== Features =====
 +
 +  * reconnects after Netsplit or kick
 +  * reloads configuration files
 +  * restarts itself on changes for database or irc configuration
 +  * supports MSS (Message Storage System)
 +  * implements test function for proper monitoring
 +  * implements proper logging (inlc. debug mode)
 +  * supports different configuration files (e.g. for testing)
 +
 +==== MSS (Message Storage System) ====
 +
 +This system is designed by Andrwe.
 +
 +It stores messages addressed to someone in the channel who isn't online anymore in a database.\\
 +After reconnecting of the addressed user the message is send to him as private message including the link to irc log website.
 +
 +It is activated by starting the message with '@Nickname' e.g. @Andrwe.
 +
 +Currently the messages are only deleted after there were successfully send to the target.
  
 ===== Usage ===== ===== Usage =====
Line 14: Line 35:
 </code> </code>
  
-On the server of dokuwiki an init-script exists:+On the server of dokuwiki a [[#systemd-file]] exists:
 <code> <code>
-# start +# start bot 
-service irclog start +systemctl start irclog 
-# stop +# stop bot 
-service irclog stop +systemctl stop irclog 
-# restart +# restart bot 
-service irclog restart +systemctl restart irclog 
-# reload +# reload bot 
-service irclog reload+systemctl reload irclog 
 +# checks running bot 
 +systemctl status irclog
 </code> </code>
  
-===== Functions =====+For testing purpose there is irclog-test init-script. It starts a bot using /var/www/irclog/htdocs/test.conf.php as configuration file.
  
-  * reconnects after Netsplit or kick +===== Configuration =====
-  * reloads configuration files +
-  * restarts itself on changes for database or irc configuration +
-  * supports MSS (Message Storage System) +
-  * implements test function for proper monitoring +
-  * implements proper logging (inlc. debug mode) +
-  * supports different configuration files (e.g. for testing)+
  
-==== MSS (Message Storage System) ====+==== Main ====
  
-This system is designed by Andrwe.+There is an example configuration file in the git.\\ 
 +Move that to irclog.config.php within the directory of the bot-script (irclog.pl) and adapt it.
  
-It stores messages addressed to someone in the channel who isn't online anymore in a database.\\ +The parameters you have to change are: 
-After reconnecting of the addressed user the message is send to him as private message including the link to irc log website.+  * db_host 
 +  * db_user 
 +  * db_pass 
 +  * db_name 
 +  * irc_host 
 +  * irc_port 
 +  * irc_chan 
 +  * irc_nick 
 +  * irc_name 
 +  * irc_pass 
 +  * initscript
  
-It is activated by starting the message with '@Nickname' e.g. @Andrwe.+The parameters you might want to change: 
 +  * *_log 
 +  * irc_* for automatic messages
  
-Currently the messages are only deleted after there were successfully send to the target.+==== Special commands ====
  
-===== TODO =====+The file ''irclog.special.pl'' is loaded by the bot and contains the funciton ''special()''.\\ 
 +This function implements bot commands by checking for commands within the message. 
 +===== Init-script =====
  
-  * check for already running process +The following can be used to control the bot on Debian systems. Just copy it to ''/etc/init.d/irclog''.
-  * increase error checks +
-  * increase error logging +
-  * write help command +
-  * msgstore cleanup +
-  * zabbix monitoring+
  
-===== old version =====+<file bash /etc/init.d/irclog> 
 +#! /bin/sh 
 +### BEGIN INIT INFO 
 +# Provides:          irclog 
 +# Required-Start:    $remote_fs 
 +# Required-Stop:     $remote_fs 
 +# Default-Start:     2 3 4 5 
 +# Default-Stop:      0 1 6 
 +# Short-Description: start dokubot (irclogger) 
 +# Description:       start dokubot for logging IRC messages 
 +### END INIT INFO
  
-DokuBot is our IRC botOn netsplits or when MySQL goes down, the bot dies. [[user>ach|Anika]] is usually the first one to notice. Here's how to restart it:+# Author: dokuwiki.org (Andrwe)
  
-  $> sudo su - +PATH=/sbin:/usr/sbin:/bin:/usr/bin 
-  #> /etc/init.d/irclog stop+DESC="IRC logging service" 
 +NAME=irclog.pl 
 +DAEMON=/var/www/irclog/htdocs/$NAME 
 +PIDFILE=/var/run/$NAME.pid
  
-Now it should be gone. In reality it probably isn't. Check with ps ax and kill it:+# Exit if the package is not installed 
 +[ -x "$DAEMON" ] || exit 1
  
-  #> ps ax |grep irc +Load the VERBOSE setting and other rcS variables 
-  11669 ?        S      4:46 /usr/bin/perl ./irclogger.pl +/lib/init/vars.sh
-  #> kill 11669+
  
-Then restart+# Define LSB log_* functions. 
 +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 
 +. /lib/lsb/init-functions
  
-  #/etc/init.d/irclog start+
 +# Function that starts the daemon/service 
 +
 +do_start() 
 +
 +    # Return 
 +    #   0 if daemon has been started 
 +      1 if daemon was already running 
 +    #   2 if daemon could not be started 
 +    start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog -b --exec $DAEMON -- -s  \ 
 +        || return 2 
 +}
  
-To check if it's alive join the IRC channel and ask him for a beer.+
 +# Function that stops the daemon/service 
 +
 +do_stop() 
 +
 +    # Return 
 +    #   if daemon has been stopped 
 +    #   1 if daemon was already stopped 
 +    #   2 if daemon could not be stopped 
 +    #   other if a failure occurred 
 +    start-stop-daemon --stop --quiet --name $NAME -- -x 
 +    RETVAL="$?" 
 +    [ "$RETVAL" = 2 ] && return 2 
 +    return "$RETVAL" 
 +
 + 
 +do_reload() 
 +
 +    start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog --exec $DAEMON -- -r \ 
 +        || return 1 
 +
 + 
 +do_check() 
 +
 +    return start-stop-daemon --start --quiet -d /var/www/irclog/htdocs -c irclog --exec $DAEMON -- -t 
 +
 + 
 +case "$1" in 
 +  start) 
 +    log_daemon_msg "Starting $DESC" "$NAME" 
 +    do_start 
 +    case "$?" in 
 +        0|1) log_end_msg 0 ;; 
 +        2) log_end_msg 1 ;; 
 +    esac 
 +    ;; 
 +  stop) 
 +    log_daemon_msg "Stopping $DESC" "$NAME" 
 +    do_stop 
 +    case "$?" in 
 +        0|1) log_end_msg 0 ;; 
 +        2) log_end_msg 1 ;; 
 +    esac 
 +    ;; 
 +  reload) 
 +    log_daemon_msg "Reloading $DESC" "$NAME" 
 +    do_reload 
 +    case "$?" in 
 +        0) log_end_msg 0 ;; 
 +        1) log_end_msg 1 ;; # Old process is still running 
 +        *) log_end_msg 1 ;; # Failed to start 
 +    esac 
 +    ;; 
 +  check) 
 +    log_daemon_msg "Checking $DESC" "$NAME" 
 +    do_check 
 +    case "$?" in 
 +        0) log_end_msg 0 ;; 
 +        1)  
 +            log_end_msg 1 
 +            log_daemon_msg "Couldn't run test." "$NAME" 
 +            ;; 
 +        2)  
 +            log_end_msg 1 
 +            log_daemon_msg "Test failed. To fix it you have to restart the bot." "$NAME" 
 +            ;; 
 +        3)  
 +            log_end_msg 1 
 +            log_daemon_msg "Test failed. To fix it you have to restart the bot." "$NAME" 
 +            ;; 
 +        *)  
 +            log_end_msg 1 
 +            ;; 
 +    esac 
 +    ;; 
 +  restart) 
 +    log_daemon_msg "Restarting $DESC" "$NAME" 
 +    do_stop 
 +    case "$?" in 
 +      0|1) 
 +        do_start 
 +        case "$?" in 
 +            0) log_end_msg 0 ;; 
 +            1) log_end_msg 1 ;; # Old process is still running 
 +            *) log_end_msg 1 ;; # Failed to start 
 +        esac 
 +        ;; 
 +      *) 
 +          # Failed to stop 
 +        log_end_msg 1 
 +        ;; 
 +    esac 
 +    ;; 
 +  *) 
 +    echo "Usage: $0 {start|stop|restart|reload}" >&
 +    exit 3 
 +    ;; 
 +esac 
 +</file> 
 + 
 +===== TODO ===== 
 + 
 +  * check for already running process 
 +  * increase error checks 
 +  * increase error logging 
 +  * write help command 
 +  * msgstore cleanup 
 +  * zabbix monitoring 
 +  * [[https://github.com/splitbrain/irclogger/issues]]
teams/dokubot.txt · Last modified: 2015-05-21 02:38 by andrwe

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki