Discussion:
sic - remove stdout formatting?
Josh Rickmar
2009-10-19 20:04:12 UTC
Permalink
I would like to (re)write an irc bot using sic, but the formatted output
is making this harder then it could/should be. For example, the first
field, the channel or irc server, is cut off at 12 characters by a
colon. This becomes a problem when trying to parse the output because
longer field names can be cut off. It can also cause the number of
fields (seperated by whitespace) to change since a field with >=12
characters will be missing a space between the name and the colon.

To make this program more useful, wouldn't it be better if all the
information was presented to the user? Doing so would make writing bots
much easier and would allow the user to easily format the output any way
he/she wants to by passing sic's output to awk.

Josh Rickmar
Kris Maglione
2009-10-19 20:18:32 UTC
Permalink
Post by Josh Rickmar
I would like to (re)write an irc bot using sic, but the formatted output
is making this harder then it could/should be. For example, the first
field, the channel or irc server, is cut off at 12 characters by a
colon. This becomes a problem when trying to parse the output because
longer field names can be cut off. It can also cause the number of
fields (seperated by whitespace) to change since a field with >=12
characters will be missing a space between the name and the colon.
To make this program more useful, wouldn't it be better if all the
information was presented to the user? Doing so would make writing bots
much easier and would allow the user to easily format the output any way
he/she wants to by passing sic's output to awk.
I've written IRC bots with sic before, and made the same
modification. Try kris/sic.c from the hg repo.
--
Kris Maglione

He hoped and prayed that there wasn't an afterlife. Then he realized
there was a contradiction involved here and merely hoped that there
wasn't an afterlife.
--Douglas Adams
Josh Rickmar
2009-10-19 20:42:59 UTC
Permalink
Post by Kris Maglione
Post by Josh Rickmar
I would like to (re)write an irc bot using sic, but the formatted output
is making this harder then it could/should be. For example, the first
field, the channel or irc server, is cut off at 12 characters by a
colon. This becomes a problem when trying to parse the output because
longer field names can be cut off. It can also cause the number of
fields (seperated by whitespace) to change since a field with >=12
characters will be missing a space between the name and the colon.
To make this program more useful, wouldn't it be better if all the
information was presented to the user? Doing so would make writing bots
much easier and would allow the user to easily format the output any way
he/she wants to by passing sic's output to awk.
I've written IRC bots with sic before, and made the same
modification. Try kris/sic.c from the hg repo.
Ah, thanks. Yeah, much better.

Josh Rickmar
Anselm R Garbe
2009-10-20 07:19:04 UTC
Permalink
Post by Josh Rickmar
I would like to (re)write an irc bot using sic, but the formatted output
is making this harder then it could/should be. For example, the first
field, the channel or irc server, is cut off at 12 characters by a
colon. This becomes a problem when trying to parse the output because
longer field names can be cut off. It can also cause the number of
fields (seperated by whitespace) to change since a field with >=12
characters will be missing a space between the name and the colon.
To make this program more useful, wouldn't it be better if all the
information was presented to the user? Doing so would make writing bots
much easier and would allow the user to easily format the output any way
he/she wants to by passing sic's output to awk.
I've written IRC bots with sic before, and made the same modification. Try
kris/sic.c from the hg repo.
That reminds me that I want to merge your stuff ;) Will do that during
next days.

Kind regards,
Anselm
s***@cs.tu-berlin.de
2009-10-20 09:28:46 UTC
Permalink
Is there anybody using sic not for bots only? I mean, I use it with bitlbee
for all my IM stuff -- primary jabber & icq, but occasionally, sadly yahoo
+ msn,too.

Actually, I patched sic to

- do something on particular string pattern, which I specify as command
line argument, e.g. like this:

% sic [other options] -e "<(contact1|contact2.*)> *beep?$HOME/.sic/beep"

which will execute ~/.sic/beep every time contact1 send me the message
'beep'.
- to set the default contact to the one I wrote to, every time I send a
message.

Furhter, I hacked together a zsh wrapper and start sic like this:

LOG="$HOME/.sic/log.`date +%F`"
ZDOTDIR=~/.sic zsh |\
sic \
-h localhost \
-p 12345 \
-n stanio \
-e "<(contact1|contact2.*)> *beep?$HOME/.sic/beep" |\
tee -a "$LOG"

where .sic/.zshrc contains some functions like


basic_send() { echo "$@" $REDIRECT }
sic_send() { basic_send ":""$@" }
msg() {
rec=$1
shift
sic_send m "$rec" "$@"
PROMPT="%***@sic|$rec> "
}
multisend() {
msg="$1"
shift
for contact in $@; do msg "$contact" "$msg"; done
}
PROMPT='%***@sic> '
RPROMPT="|%D{%Y-%m-%d %a %H:%M'%S}"
# [...] + other stuff

The idea was to have
- some functions for convenience
- a prompt which shows me which is the current default contact,
- basic completion for contacts and commands using the zsh framework.

But I never got the latter done because I never got the time to figure out
how completion works in zsh, which turned out not to be as simple as I
assumed... So, now it's slightly more overhead than benefit.

I'll be glad to read some 'best practice's for sic, if anybody is
willing to share here?

cheers
--
stanio_
Claudio M. Alessi
2009-10-20 12:02:06 UTC
Permalink
Post by Josh Rickmar
I would like to (re)write an irc bot using sic, but the formatted output
is making this harder then it could/should be. For example, the first
field, the channel or irc server, is cut off at 12 characters by a
colon. This becomes a problem when trying to parse the output because
longer field names can be cut off. It can also cause the number of
fields (seperated by whitespace) to change since a field with >=12
characters will be missing a space between the name and the colon.
To make this program more useful, wouldn't it be better if all the
information was presented to the user? Doing so would make writing bots
much easier and would allow the user to easily format the output any way
he/she wants to by passing sic's output to awk.
Josh Rickmar
+1

It would be better to customize output using sic in pipe with an ad-hoc tool
(likely the most useful is awk). There's no need to formatting the output, also
why the actual sic output is not much more formatted than the original text
sent by the server, it's just a bit reordered. It also would be nice to avoid
commands like 'j' or 'l' which could easily be replaced by the original "join"
and "part" commands, removing few (useless?) LOCs. Apart from this, sic is the
perfect IRC client (and it's said by an old weechat user :-P).

Regards,
Claudio M. Alessi
--
JID: smoppy AT gmail.com
WWW: http://cma.teroristi.org
Loading...