Visit Our UNIX and Linux User Community


Using ii for irc chat - scripting assistance?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using ii for irc chat - scripting assistance?
# 1  
Old 01-19-2012
Using ii for irc chat - scripting assistance?

I am using ii for irc on my pogoplug...

hxxp://hg.suckless.org/ii/file/d163c8917af7/FAQ

If you look at the bottom of there, it states

Code:
    31 What other fancy stuff can I do with ii?
    32 ----------------------------------------
    33 It is very easy to write irc bots in ii:
    34 tail -f \#/out | while read foo; do name=echo $foo | awk '{print $2}' | sed 's,<\\(.*\\)>,\\1,'; if 0 -eq expr $RANDOM % 10 then echo "$name: WHAT??" ; fi; done
    35 This will just spam a channel but think about using nagios2irc or you can
    36 use ii to generate channel stats. Your imagination should be boundless.

Now, forgive me, but I more or less have no idea what that is doing.


My goal is to do something similiar to what this normal irc remote script will do, but with ii

Code:
on 1:TEXT:*:#channel_name:if (your_text_trigger isin $1-) { msg your_nickname_to_message from $nick ( $chan ) said $1- }

Basically, whenever someone says a trigger in a particular channel, it will message a nickname with that entire line.

The channel output is stored in a file named "out". When the trigger is stated, I'd need the name of the person who said it along with the entire line of what they said (containing the trigger as well) sent to "in" along with the command to private message it.

Is that possible with ii, from what you can see?

---------- Post updated 01-19-12 at 01:45 PM ---------- Previous update was 01-18-12 at 09:57 PM ----------

To add some clarification .....

I need to tail a particular file which is essentially a log file. Whenever I see my name, I want it to copy that entire line to a different file.

I figure I will have to use awk to do this, but beyond that I am completely lost.

Code:
tail -f outputfile | grep -w 'trigger1|trigger2|trigger3'

That should only display things that have the trigger word in them (entire line, right?).

How can I then take that line, store it to a variable, then send some text, then the variable, to another file?

Last edited by spartan2006; 01-19-2012 at 04:28 PM..
# 2  
Old 01-19-2012
You may try something like this:

Code:
tail -f outputfile | 
  while IFS= read -r ;do
    case $REPLY in
      ( *trigger[1-3]* ) 
          printf '%s\n%s\n' '<some_text>' "$REPLY" >> another_file ;;
    esac
  done

# 3  
Old 01-19-2012
I'm not surprised you can't make heads or tails of that channel-spamming code. It is pretty awful. Smilie

Of all that code you posted, not one bit shows how anything's fed into ii however, so I'm almost as confused as you are. I can only guess that ii runs scripts, rather than scripts running ii...
# 4  
Old 01-19-2012
Really at this point (in reference to how ii works), I just need ways to manipulate log files.


There's an in and out file for each server / channel / person, separated by folders for each. So what I need to do is take the file

~/irc/servername/channelname/out

and monitor for the trigger word(s).


I then need to take that entire line of text and hopefully put it in a variable.


I then need to have the following sent to ~/irc/servername/in

/privmsg my_nickname [stored string of data from above]



Does that kind of clear things up a little, as far as how ii works and what I'm attempting to do?


My ultimate goal is to be able to start the file/bash script and be able to close out of the ssh session to the pogoplug while keeping this running so I can leave it idling as a bot in the room.

Previous Thread | Next Thread
Test Your Knowledge in Computers #820
Difficulty: Easy
Before CSS, nearly all presentational attributes of HTML documents were contained within the HTML markup.
True or False?

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Noob to scripting needs some assistance

Hello, I am in a Unix class and have been out of town. I have been tasked to generate a couple of scripts and ahve never done it before. I have a virtual machine running Ubuntu. The task is below Prompt the system administrator for all valid input parameters Generate a menu to ask which... (1 Reply)
Discussion started by: jkeeton81
1 Replies

2. Shell Programming and Scripting

Dhcp.config file scripting assistance

Hello everyone! I am brand new at this forum thing and wanted to thank all of you for your time and help in advance for helping me troubleshoot my issue. I am fairly new to shell scripting and scoured the entire internet to find a solution for my issue to no avail and hope you're able to help. ... (2 Replies)
Discussion started by: sedrocks
2 Replies

3. Shell Programming and Scripting

sed newbie scripting assistance

Howdy folks, I'm trying to craft a log file summarisation tool for an application that creates a lot of duplicate entries with only a different suffix to indicate point of execution. I thought I'd gotten close but I'm clearly missing something. Here's a genericized version: A text_file... (3 Replies)
Discussion started by: mthespian
3 Replies

4. Shell Programming and Scripting

Assistance in Perl scripting

PFA file "color.txt". Note : There is no newline character in the file. I have manually inserted the newline char to make it easy to understand. I am expecting out in the form as specified in second file "out.txt" I need a perl script to perform the task. Thanks in advance. (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

5. Shell Programming and Scripting

Scripting neophyte needs file manipulation assistance

I need to write two shell scripts for an rsync backup solution. The first script will copy all backed up files into a folder named after the original folder, plus a date stamp (so e.g. if the original folder name is 'foo' and is backed up on the 10th of September, then the backup folder will be... (0 Replies)
Discussion started by: LambdaCalculus
0 Replies

Featured Tech Videos