IRC:exec: Difference between revisions

From SoylentNews
Jump to navigation Jump to search
Line 85: Line 85:
*%%params%%
*%%params%%


:<prefix> <command> <params> :<trailing>
<source lang="dot">:<prefix> <command> <params> :<trailing></code>


Example script:
Example script:

Revision as of 09:34, 26 April 2014

IRC Script Executive

"exec" is a script that runs in a CLI that connects to the Soylent IRC server (irc.sylnt.us:6667) and executes other programs for output to an IRC channel.

Input to a script/program is via command line arguments only (stdin is not supported).

stdout of an executed script/program may be passed to an IRC channel or output to exec's stdout (terminal), depending on the value of auto-privmsg in the exec line. If auto-privmsg=0, stdout from the script/program must begin with "privmsg " for it to be sent to the IRC channel.

Programs executed may be anything accessible from the CLI of the machine running the exec script. They may be shell programs (such as cowsay and fortune), php scripts (executed using the CLI php command) or scripts in any other language executable by their respective CLI interpreters (python, perl, etc).

Developer(s): crutchy

Source: https://github.com/crutchy-/test

Files:

Usage

Download above files from github into the same directory, open a terminal and change to that directory, and run "php irc.php".

Scripts may be stored anywhere that is accessible to bacon for CLI execution. If stored in a different location, be sure to include a path in the exec file line.

To invoke a script in IRC client:

alias [msg]

Example:

<crutchy> define atlantic ocean
  <bacon> 1 | noun | the 2nd largest ocean; separates North and South America on the west from Europe and Africa on the east\n2 | adjective | relating to or bordering the Atlantic Ocean

In the above example, "define" is the command alias, "atlantic ocean" is passed to the script as %%msg%%

About:

~

Exec file:

# alias|timeout(sec)|auto-privmsg(1|0)|empty-trailing-allowed(1|0)|cmd
# available templates: %%trailing%%, %%dest%%, %%nick%%, %%start%%, %%alias%%, %%cmd%%, %%data%%, %%exec%%, %%params%%
# %%trailing%% excludes alias

# EXEC ON ALL LINES (ONLY ONE EXEC LINE ALLOWED SO ADD TO COMMAND USING &&
*|5|0|0|php scripts/grab.php %%trailing%% %%nick%% && php scripts/cmd.php %%cmd%% %%trailing%% %%data%% %%dest%% %%params%% %%nick%%

~|5|1|1|php scripts/about.php
cowsay|5|1|0|cowsay %%trailing%%
snake|5|1|1|echo %%trailing%% | cowsay -f elephant-in-snake
test|5|0|0|php scripts/test.php %%trailing%% %%dest%% %%nick%%
ps|5|1|1|ps fl
moo|10|1|1|apt-get moo
fortune|5|1|1|fortune -s
cowsay-fortune|5|1|1|sh cowsay-fortune.sh
define|10|0|0|php scripts/definitions.php %%trailing%%
php|5|0|0|php scripts/php.php %%trailing%%
smile|5|1|0|php scripts/smile.php %%trailing%%
uptime|5|1|1|uptime
rofl|5|1|1|fortune -s
exec-up|5|0|1|php scripts/up.php %%start%%
bsod|10|1|1|php scripts/bsod.php
~join|5|0|0|php scripts/join.php %%trailing%%
~part|5|0|1|php scripts/part.php %%dest%% %%trailing%%
~recurse|5|0|1|php scripts/recurse.php
~bucket|5|0|1|php scripts/buckets.php

weather|10|0|1|php scripts/weather.php %%alias%% %%trailing%%
weather-add|10|0|1|php scripts/weather.php %%alias%% %%trailing%%

civ|5|0|1|php scripts/irciv.php %%nick%% %%trailing%% %%dest%%

# non-php scripts
haskell|5|1|1|runhaskell scripts/haskell.hs
perl|5|1|1|perl scripts/perl.pl

Available exec templates:

  • %%trailing%%
  • %%dest%%
  • %%nick%%
  • %%start%% # microtime(True) result when bot was started
  • %%alias%%
  • %%cmd%%
  • %%data%%
  • %%exec%%
  • %%params%%
:<prefix> <command> <params> :<trailing></code>

Example script:
<source lang="php">
<?php
# 5|0|0|test|php test.php "%%msg%%" "%%chan%%" "%%nick%%"
echo "when auto-privmsg=0 this shows on terminal (stdout) only\n";
echo "privmsg msg=".$argv[1]."\n";
echo "privmsg chan=".$argv[2]."\n";
echo "privmsg nick=".$argv[3]."\n";
?>

If anyone is interested in adding their own script, do a github fork/pull and/or let crutchy know (crutchy usually hangs out in #soylent, ## and #test).

weather exec script

Developer(s): crutchy

Source: https://github.com/crutchy-/test/blob/master/weather.php

Available commands:

  • weather location
  • weather-add code location

note: weather-add code location will change the location of the code if the code has already been entered. Currently, codes cannot be deleted.

A few thousand ICAO and IATA/FAA airport codes have been imported into the codes file thanks to OpenFlights.

Usage examples

<crutchy> weather
<exec> SOYLENT IRC WEATHER INFORMATION BOT
<exec>   usage: "weather location" (visit http://wiki.soylentnews.org/wiki/IRC#weather for more info)
<exec>   data courtesy of the APRS Citizen Weather Observer Program (CWOP) @ http://weather.gladstonefamily.net/
<exec>   by crutchy: https://github.com/crutchy-/test/blob/master/weather.php


<crutchy> weather JFK
<exec> Weather for Brooklyn, NY US at 2014-04-14 03:36:00 (UTC) ~ 0.8 hrs ago:
<exec>     temperature = 66°F (18.9°C)    dewpoint = 56.3°F (13.5°C)
<exec>     barometric pressure = 1017.3 mb ~ change of 0 mb over past 0.2 hrs    relative humdity = 71%
<exec>     wind speed = 1 mph (1.6 km/h)    wind direction = 336°


<kobach> weather vostok, aq
<exec> Weather for Vostok Station (RUS), -, Antarctica (the territory South of 60 deg S) at 2014-04-14 12:00:00 (UTC) ~ 0.8 hrs ago:
<exec>     temperature = -83.7°F (-64.3°C)    dewpoint = -90.9°F (-68.3°C)
<exec>     barometric pressure = 948.9 mb ~ change of 1.6 mb over past 6 hrs    relative humdity = 57%
<exec>     wind speed = 10 mph (16 km/h)    wind direction = 200°


<crutchy> weather-add crutchy melbourne australia
<exec> code "crutchy" set for location "melbourne australia"


<crutchy> weather crutchy
<exec> Weather for Melbourne Regional Office, VIC, Australia at 2014-04-14 11:00:00 (UTC) ~ 0.8 hrs ago:
<exec>     temperature = 60.4°F (15.8°C)    dewpoint = 50.2°F (10.1°C)
<exec>     barometric pressure = 1023.5 mb ~ change of -1.4 mb over past 3 hrs    relative humdity = 68%
<exec>     wind speed = (no data)    wind direction = 0°