| index.md - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| index.md (3881B) | |
| --- | |
| 1 Bots | |
| 2 ==== | |
| 3 Its very easy to write shell script based bots with ii. As a short examp… | |
| 4 at this: | |
| 5 | |
| 6 tail -f \#<CHANNEL>/out | | |
| 7 while read -r date time nick mesg; do | |
| 8 nick="${nick#<}" | |
| 9 nick="${nick%>}" | |
| 10 printf "%s: WHAT??\n" "$nick" | |
| 11 done >#<CHANNEL>/in | |
| 12 | |
| 13 Its just spamming a channel but I guess your imagination is boundless. I… | |
| 14 heard about people using it together with nagios to get the notification… | |
| 15 IRC. Remember to strip input for example with tr(1), tr -cd "0-9a-zA-Z" … | |
| 16 example would only allow numbers and characters. | |
| 17 | |
| 18 If you want to see a live demonstration of a bot written for ii, join #g… | |
| 19 freenode, the grml-tips bot which searches for [grml](http://www.grml.or… | |
| 20 and gives a link or error messages is written in 45 lines of /bin/sh. No… | |
| 21 will not publish the code since I really suck in shell programming :) | |
| 22 | |
| 23 Stat scripts | |
| 24 ------------ | |
| 25 If you want to use for example [pisg](http://pisg.sf.net/) to generate c… | |
| 26 stats this will also work if you choose the irssi log format. | |
| 27 | |
| 28 Automatic reconnects | |
| 29 -------------------- | |
| 30 If you want some kind of automatic reconnects in ii you can make a somet… | |
| 31 like this in a shell script: | |
| 32 | |
| 33 while true; do | |
| 34 ii -s irc.oftc.net -n iifoo -f "John Doe" & | |
| 35 iipid="$!" | |
| 36 sleep 5 | |
| 37 printf "/j %s\n" "#ii" > ~/irc/irc.oftc.net/in | |
| 38 wait "$iipid" | |
| 39 done | |
| 40 | |
| 41 bots for irc it (ii) | |
| 42 ==================== | |
| 43 | |
| 44 iibot | |
| 45 ----- | |
| 46 [iibot](https://github.com/c00kiemon5ter/iibot) by c00kiemon5ter is writ… | |
| 47 bash, but can easily be translated to plain sh (ask him). | |
| 48 | |
| 49 It uses a main script to connect to multiple servers and channels, and | |
| 50 auto-reconnect and auto-join on network failure. | |
| 51 | |
| 52 It reads commands with a leading '!' and calls a secondary script to han… | |
| 53 command and the responce. That way commands can be added or removed | |
| 54 dynamically. The secondary script knows the network, channel, nick and m… | |
| 55 that triggered the command, so it is easy to filter responses to command… | |
| 56 specified channels, users and such. | |
| 57 | |
| 58 if you need help, do not hesitate to ask c00kiemon5ter on freenode and o… | |
| 59 | |
| 60 nagios | |
| 61 ------ | |
| 62 Simple Perl script "nagios\_post.pl" as interface between | |
| 63 [Nagios](http://www.nagios.org/) and ii: | |
| 64 | |
| 65 #!/usr/bin/perl -w | |
| 66 | |
| 67 my $users = "your_nickname(s)"; | |
| 68 my $pipe = "$ENV{HOME}/irc/your_irc_server/#your_channel/in"; | |
| 69 my %color = ( | |
| 70 red => "\0034", | |
| 71 purple => "\0036", | |
| 72 yellow => "\0038", | |
| 73 clear => "\00315", | |
| 74 blue => "\0032\002", | |
| 75 green => "\0033", | |
| 76 normal => "\0031", | |
| 77 ); | |
| 78 | |
| 79 open(PIPE, '>', $pipe) or die "Can't write to $pipe: $!"; | |
| 80 while (<>) { | |
| 81 s/Host [a-z0-9_.]+ is down/$color{red}$&$color{normal}/i; | |
| 82 s/PROBLEM.*?CRITICAL/$color{red}$&$color{normal}/i; | |
| 83 | |
| 84 s/PROBLEM.*?WARNING/$color{yellow}$&$color{normal}/i; | |
| 85 s/Host [a-z0-9_.]+ is up/$color{green}$&$color{normal}/i; | |
| 86 | |
| 87 s/RECOVERY.*?OK/$color{green}$&$color{normal}/i; | |
| 88 | |
| 89 print PIPE "$users: $_"; | |
| 90 } | |
| 91 close(PIPE); | |
| 92 | |
| 93 The appropriate Nagios configuration looks like this: | |
| 94 | |
| 95 # 'notify-by-irc' command definition | |
| 96 define command{ | |
| 97 command_name notify-by-irc | |
| 98 command_line /usr/bin/printf "%b" "$TIME$ $NOTIFICATI… | |
| 99 } | |
| 100 | |
| 101 # 'host-notify-by-irc' command-notification | |
| 102 define command{ | |
| 103 command_name host-notify-by-irc | |
| 104 command_line /usr/bin/printf "%b" "$TIME$ Host $HOSTA… | |
| 105 } | |
| 106 | |
| 107 Start ii appropriately and add notify-by-irc and host-notify-by-irc to t… | |
| 108 appropriate "service_notification_commands" and | |
| 109 "host_notification_commands" -- and you have your own Nagios I… | |
| 110 | |
| 111 rsstail | |
| 112 ------- | |
| 113 Just piping the output of [rsstail](http://www.vanheusden.com/rsstail/) … | |
| 114 the fifo "in" should work. More detailed examples are welcome. |