IRC:exec

From SoylentNews
Revision as of 03:32, 26 April 2014 by Chromas (talk | contribs) (Created page with "{{DISPLAYTITLE: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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


"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:

# timeout(sec)|auto-privmsg(1|0)|empty-msg-allowed(1|0)|alias|cmd
# available templates: %%msg%%, %%chan%%, %%nick%%, %%start%%, %%alias%%
# %%msg%% excludes alias

5|1|0|cowsay|cowsay %%msg%%
5|0|0|test|php test.php %%msg%% %%chan%% %%nick%%
5|1|1|ps|ps
5|1|1|moo|apt-get moo
5|1|1|fortune|fortune -s
5|1|1|cowsay-fortune|sh cowsay-fortune.sh
10|0|0|define|php definitions.php %%msg%%
5|0|0|php|php php.php %%msg%%
5|1|0|smile|php smile.php %%msg%%
5|1|1|uptime|uptime
5|1|1|rofl|fortune -s
5|0|1|bacon-up|php up.php %%start%%

5|1|1|haskell|runhaskell haskell.hs
5|1|1|perl|perl perl.pl

10|0|1|weather|php weather.php %%alias%% %%msg%%
10|0|1|weather-add|php weather.php %%alias%% %%msg%%

5|0|1|civ|php irciv/irciv.php %%nick%% %%msg%%

# EXEC ON ALL LINES (ONLY ONE EXEC LINE ALLOWED SO ADD TO COMMAND USING &&
5|0|0|*|php grab.php %%msg%% %%nick%%

Available exec templates:

  • %%msg%%
  • %%chan%%
  • %%nick%%
  • %%start%% # microtime(True) result when bot was started
  • %%alias%%


Example script:

<?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°