Showtitle is an Irssi script that scans the current private, public or action message for a string matching a URL specification. If it finds one, it then tries to get the beginning of the URL contents in order to parse out the <title></title> tag, and then attempts to show it either to the channel, or to the script user.
Showtitle is an active bot script, i.e, it responds to certain types of text on channels it is listening on.
The channel text to invoke showtitle commands is "!st" at the beginning of the line.
Determines whether showtitle will be listening to a particular channel.
on - turn listening on for this chatnet/channel
off - turn listening off for this chatnet/channel
list - show current channels listened to on this chatnet
help - send help info about listen command to nick that entered
the !st command
Modifies the filters for the current chatnet/channel. If no filters are specified, and listening is on for this chatnet/channel, then all URL title are sent to the channel. Filters are pass filters, rather than no-pass filters, i.e. they determine what is allowed to send to the channel.
add <regex> -- add the regex to the filter list
delete <regex> -- remove the regex from the filter list
list -- show current set of filters on this chatnet/channel
help -- display help info to the calling nick
Deal with eligible users for managing the showtitle bot. Eligible users are determined by the address part of their hostmask.
add -- add a user to the showtitle bot's user list
delete -- delete a user from showtitle bot's user list
request [address] -- make a request to the bot owner to add
someone to the list. If address is not specified, then the calling
user's address is used.
list -- list the current users
help -- send a help message to calling nick
send general help to calling user.
These commands are available to the user running the showtitle script.
modify user list
modify filter list
modify listening list
Completely ignore any ^! input from the channel. This has the effect of essentially hiding showtitle from anyone attempting to determine if there are any bots listening
on - turn on ignore on this chatnet/channel
off - turn off ignore on this chatnet/channel
list - show ignored channels on this chatnet
save current configuration
show current status across all chatnets/channels
turns debugging for showtitle script on or off, or reports status
The following globals are used to enable useful error messages from deep inside some of the functions.
$current_chatnet - stores the name of the current chatnet that the signal was triggered from..
$current_channel - stores the name of the current channel that the signal was triggered from.
$current_url - the matching URL in the signal's data, if any
$empty_re - a regular expression that matches an empty line
$debug - flag used to check if debugging output should be sent or not
$line_prefix - the text shown by showtitle when it writes to the channel before the title is given
$line_prefix_re - regular expression needed to match $line_prefix
%listen_on - determines where we are listening = (chatnet => {channel => listening,})
%filters - filters to apply on a per-channel basis = (chatnet => {channel => (filter_regexp)})
%validusers - which users are allowed to do certain commands = (chatnet => {channel => (address)})
%ignores - enforces ignore on specific chatnet channels = (chatnet => {channel => ignoring (on/off)})
$major, $minor, and $subminor
$database_basename - the name of the data base used to store information, suffixed by major version number
$irssi_dir - the directory containing current irssi session's parameters, set by --home command line paramter
$database - full database path name
$database_tmp - full temporary database path name
$database_old - full backup database path name
Print a message to the current window with some debugging information if $debug is true.
Prepare a message for output to Irssi by making sure anything needed is escaped. Currently, that's only the percent sign (%).
Nicely format a string to show up on the user's current window
Nicely format an error messge string to show up on the user's current window
Say a message to the specified server/channel
send an action message to the current chatnet/channel
send a string to the current window
convert the passed string to lower case, special for irc
convert the passed string to upper case, special for irc
Process a listen database entry
process the filter database entry
process a user database entry
process an ignore database entry
Report a syntax error reading and processing the database
An associative array containing a jump table to handle each database entry type. Structure is:
reads and processes the various entries in the database
Writing the database to file
Append an entry to the database
Retrieve the header of the given URL to see if it contains HTML code
get the page for the specified URL -- possibly only a fragment
description:
Uses curl (command line version) to pull over the contents of the specified URL. The curl command is set to be silent, unless the command fails. Other parameters to the curl command include the output file name, the user agent string, a connect timeout and a max timeout, and to follow relocation headers (302s) from the web server.
Pull the title from the contents and clean it up
Extract the url from the message text
find_url will match on the text for various URL schemes (currently only supporting FTP and HTTP). In addition, if the bareword "www" precedes a triple-word, it is treated as an HTTP URL and modified accordingly.
Check to see if the url passes various filters
Main logic of the script -- display the title of a given URL on either the target's channel, or to the user's screen
showtitle checks the message to see if it contains a valid URL string (currently only ftp: and http: are supported). showtitle will also match if the string begins with "www". It then checks to see if the URL contains an HTML content type.
Checks to see if calling user is in the list of valid users
Process an !st listen on/off request
List the current channels being listened to for urls
Provide help to the calling user, sent as private message.
Show whether the current chatnet/channel is being listened to
Add a filter to the current channel. Filters are treated as regexes. If a filter is specified as "qr/.../", then it will be evaled as is, if it isn't, then "qr/" and "/" will be wrapped around what ever is given.
Deletes a given filter. Filters are regexes. If a filter is specifed with "qr/.../" then it is used as is. Otherwise "qr/" and "/" are wrapped around teh filter text and it is evaled.
Give a list of filters on the current channel
Send help messages to calling nick as private messages
Show what the current filter status is on channel (on or off)
Add a user to the authorized users list for this channel
Remove a user to the authorized users list for this channel
Show the current set of authorized users for the chatnet/channel
Send a user request to the owner of the bot to add to authorized users
Send help info to requesting user as private messages
Say whether the requesting user is an authorized user or not
Send help info to requesting user as private messages
A jump table to determine which subroutine to use to process the command
process the command given with the st trigger
returns true if the current chatnet/channel is being ignored
Process the signals from a channel for showtitle requests and URLs
Process the signals from self for showtitle requests and URLs
Dispatch the appropriate user command.
cmd_stuser uses the Irssi::command_runsub to dispatch the appropriate subcommand based on the first word in the $data string. Commands include:
add -- add a user
delete -- remove a user
list -- list users
Add a user to the authorized user list for a given channel and chatnet
The user can specify the user to add as:
/stuser add [[[chatnet] channel] hostmask]
Delete a user based on chatnet, channel and/or hostmask
The user can specify the user to delete as:
/stuser delete [[[chatnet] channel] hostmask]
List the current set of users
Dispatch the appropriate filter command.
cmd_stfilter uses the Irssi::command_runsub to dispatch the appropriate subcommand based on the first word in the $data string. Commands include:
add -- add a filter
delete -- remove a filter
list -- list filters
Add a filter to the authorized filter list for a given channel and chatnet
The user can specify the filter to add as:
/stfilter add [[[chatnet] channel] hostmask] [qr/]regex[/]
Delete a filter to the authorized filter list for a given channel and chatnet
The user can specify the filter to delete as:
/stfilter delete [[[chatnet] channel] hostmask] [qr/]regex[/]
List the current set of filters
Dispatch the appropriate listen command.
cmd_stlisten uses the Irssi::command_runsub to dispatch the appropriate subcommand based on the first word in the $data string. Commands include:
on -- add a channel to listen on
off -- remove a channel from listening
list -- list channels listened to
Turn on listening for the specified chatnet/channel
The user can specify the listen channel as:
/stlisten on [[chatnet] channel]
Turn off listening on the specified chatnet/channel
The user can specify the filter to delete as:
/stlisten off [[chatnet] channel]
List the channels being listened to
Dispatch the appropriate ignore command.
cmd_stignore uses the Irssi::command_runsub to dispatch the appropriate subcommand based on the first word in the $data string. Commands include:
on -- add a filter
off -- remove a filter
list -- list filters
Turn on ignore for a given chatnet/channel
The user can specify the filter to delete as:
/stignore on [[chatnet] channel]
Stop ignoring a given chatnet/channel
The user can specify the filter to delete as:
/stignore off [[chatnet] channel]
Show the channels being ignored
Save the database
Give a current status of everything.
Turn debugging on or off
Usage: /stdebug [on|off]
on - turn on debugging
off - turn off debugging
omitted - show current debugging status