[Question] twitch // How can I parse text after a !submit command into a text file that I can display on screen? reddit / irc ---------------------------------------------------------------------- willpower101 · 2015-09-20 00:57 I know almost nothing about irc programming. I'm just trying to parse user submitted levels to a text file that I can queue up on screen ---------------------------------------------------------------------- ne7split · 2015-09-20 14:21 Here's a script I just knocked up for use with [Irssi](http://www.irssi.org/) in a Unix-like environment (so say Linux or if you're a Windows user in Cygwin/you could probably change the filename to a Windows filepath - I don't have a Windows environment handy). You should save the script in the Irssi scripts directory (`~/.irssi/scripts`). I'm presuming you'd call this `save.pl`. You can use it by first changing $file to a location that exists. In Irssi type `/script load save.pl`. #!/usr/bin/perl use strict; use warnings; use Irssi; use Irssi::Irc; use vars qw/%IRSSI/; %IRSSI = ( authors => 'Mike Jones', contact => 'mike@snoonet.org', name => 'DumpToFile', description => 'Save user submitted text to a file.', license => 'MIT', url => 'https://netsplit.org.uk', ); my $file = '/home/ircbots/output.txt'; Irssi::signal_add('message public', 'bootstrap'); sub bootstrap { my $server = shift; my $msg = shift; my $nick = shift; my $address = shift; my $target = shift; save_to_file($msg) if $msg =~ /^\!submit /; return; } sub save_to_file { my $msg = shift; $msg =~ s/^\!submit //s; Irssi::print("Saving '$msg' into file."); open(my $fh, '>>', $file) or die "$!"; print $fh $msg."\n"; close $fh; return; } If you wanted to save a little more detail into the file you could adjust `save_to_file` as follows: sub save_to_file { my $msg = shift; my $nick = shift; my $address = shift; $msg =~ s/^\!submit //s; Irssi::print("Saving '$msg' into file."); open(my $fh, '>>', $file) or die "$!"; print $fh "$nick!$address: $msg\n"; close $fh; return; } ---------------------------------------------------------------------- willpower101 · 2015-09-20 19:08 This looks incredibly promising and beats all my workarounds. I will play with it later today when I get off work ---------------------------------------------------------------------- ne7split · 2015-09-20 20:49 Cool. Feel free to ask if you have any problems getting it running.