<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sixserv blog &#187; irc</title>
	<atom:link href="http://sixserv.org/tag/irc/feed/" rel="self" type="application/rss+xml" />
	<link>http://sixserv.org</link>
	<description>A Blog about Linux, Networking, Development and Security.</description>
	<lastBuildDate>Tue, 27 Jul 2010 16:45:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Soup.io rbot Plugin/ ruby API</title>
		<link>http://sixserv.org/2009/02/11/soupio-rbot-plugin-ruby-api/</link>
		<comments>http://sixserv.org/2009/02/11/soupio-rbot-plugin-ruby-api/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 20:14:21 +0000</pubDate>
		<dc:creator>apoc</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[RBot]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[soup.io]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://sixserv.org/?p=313</guid>
		<description><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_ruby.png" width="50" height="51" alt="" title="Ruby" /><br/>Mit Twitter kann ich sehr leicht über meinen rbot publizieren, damit ich in der selben Frequenz auch soup.io verwende, was für spezielleren Content besser geeignet ist, muss es schon ebenfalls über den rbot funktionieren. Nach langem suchen stellte ich überrascht fest das das große Web 2.0 Projekt Soup.io keine API zum leichten publizieren(außerhalb des Browsers) [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_ruby.png" width="50" height="51" alt="" title="Ruby" /><br/><p>Mit <a href="https://twitter.com/nServ">Twitter</a> kann ich sehr leicht über meinen <a href="http://ruby-rbot.org/">rbot</a> publizieren, damit ich in der selben Frequenz auch <a href="http://apoc-sixserv.soup.io/">soup.io</a> verwende, was für spezielleren Content besser geeignet ist, muss es schon ebenfalls über den rbot funktionieren. Nach langem suchen stellte ich überrascht fest das das große Web 2.0 Projekt <a href="http://www.soup.io">Soup.io</a> <a href="http://getsatisfaction.com/soup/topics/will_there_be_some_api_for_soup_io_like_those_of_twitters">keine API</a> zum leichten publizieren(außerhalb des Browsers) besitzt. Da muss also erstmal eine art API gestrickt werden. Mit Hilfe von Mechanize baute ich die Browseranfragen nach und fasste es in einer kleinen Ruby Klasse zusammen. Es wird nicht jeder Content-Typ unterstützt aber für meine Zwecke reicht dies völlig aus. Dann noch schnell eine rbot-Plugin Klasse zum bedienen der eigenen &#8220;API&#8221; und fertig war die erste Version meines <a href="http://rbot.noway.ratry.ru/plugins/show/19">soupio-Plugins</a>.<br />
Hier eine Liste der möglichen Befehle(Argumente in eckigen Klammern sind Optional):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">soup identify <span style="color:#006600; font-weight:bold;">&lt;</span>username<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span>password<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Jeder Benutzer im Channel kann dem Bot seine 
Soup.<span style="color:#9900CC;">io</span><span style="color:#006600; font-weight:bold;">-</span>Zugangsdaten im Query mitteilen.
&nbsp;
<span style="color:#9900CC;">soup</span> login <span style="color:#006600; font-weight:bold;">=&gt;</span> Neuer Login falls die gespeicherte SessionId verloren 
oder ungültig wird. <span style="color:#006600; font-weight:bold;">&#40;</span>Normalerweise nicht notwendig.<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
soup link <span style="color:#006600; font-weight:bold;">&lt;</span>url<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&lt;</span>title<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
soup image <span style="color:#006600; font-weight:bold;">&lt;</span>url<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&lt;</span>description<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
soup text <span style="color:#006600; font-weight:bold;">&lt;</span>text<span style="color:#006600; font-weight:bold;">&gt;</span>
soup quote <span style="color:#006600; font-weight:bold;">&lt;</span>source<span style="color:#006600; font-weight:bold;">&gt;</span>: <span style="color:#006600; font-weight:bold;">&lt;</span>quote<span style="color:#006600; font-weight:bold;">&gt;</span>
soup video <span style="color:#006600; font-weight:bold;">&lt;</span>youtube<span style="color:#006600; font-weight:bold;">-</span>url<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&lt;</span>description<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></td></tr></table></div>

<p>Die SoupIoClass-Klasse kann übrigens auch außerhalb des Plugins, in jeder Ruby-Anwendung verwendet werden. Hier eine kleine Referenz, diesmal die optionalen Argumente in spitzen Klammern:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">soup = SoupIoClass.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'[Username]'</span>, <span style="color:#996600;">'[Password]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Domain]'</span>, <span style="color:#996600;">'[Session-ID]'</span><span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
soup.<span style="color:#9900CC;">new_link</span> <span style="color:#996600;">'[URL]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Title]'</span>, <span style="color:#996600;">'[Description]'</span><span style="color:#006600; font-weight:bold;">&gt;</span>
soup.<span style="color:#9900CC;">new_image</span> <span style="color:#996600;">'[URL]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Description]'</span><span style="color:#006600; font-weight:bold;">&gt;</span>
soup.<span style="color:#9900CC;">new_text</span> <span style="color:#996600;">'[Text]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Title]'</span><span style="color:#006600; font-weight:bold;">&gt;</span>
soup.<span style="color:#9900CC;">new_quote</span> <span style="color:#996600;">'[Quote]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Source]'</span><span style="color:#006600; font-weight:bold;">&gt;</span>
soup.<span style="color:#9900CC;">new_video</span> <span style="color:#996600;">'[Youtube-URL]'</span><span style="color:#006600; font-weight:bold;">&lt;</span>, <span style="color:#996600;">'[Description]'</span><span style="color:#006600; font-weight:bold;">&gt;</span></pre></td></tr></table></div>

<p>Die Domain und SessionId kann mit soup.sessid und soup.domain abgefragt werden. Die SessionId ist praktisch unbegrenzt lange haltbar, weshalb diese beiden Daten zwischengespeichert werden können um bei häufiger Nutzung der Klasse sich nicht ständig neu Anmelden zu müssen.</p>
<p>Die Version 0.1 ist bereits <a href="http://rbot.noway.ratry.ru/plugins/show/19">veröffentlicht</a>, ich muss mich noch um die Validierung und Fehlerabfragen kümmern aber sonst sollte das Plugin schon funktionieren. Fehler bitte bei mir Melden.<br />
<strong>Update:</strong> Version 0.2 veröffentlicht. (nur kleine Änderungen)<br />
<strong>Update:</strong> Version 0.3 veröffentlicht. (Bugfix für eigene Domains)<br />
<strong>Update:</strong> <a href="http://rbot.noway.ratry.ru/files/soupio-0.4.rb">Version 0.4</a> veröffentlicht. (Änderungen an soup.io)</p>
]]></content:encoded>
			<wfw:commentRss>http://sixserv.org/2009/02/11/soupio-rbot-plugin-ruby-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>xinetd: info script</title>
		<link>http://sixserv.org/2009/01/22/xinetd-info-script/</link>
		<comments>http://sixserv.org/2009/01/22/xinetd-info-script/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 18:00:29 +0000</pubDate>
		<dc:creator>apoc</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RBot]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[hddtemp]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sensors]]></category>
		<category><![CDATA[xinetd]]></category>

		<guid isPermaLink="false">http://sixserv.org/?p=142</guid>
		<description><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_linux.png" width="50" height="51" alt="" title="Linux" /><br/>Ich wollte von unterwegs aus den Status meines Heimservers abrufen können. Dabei ging es mir vorallem um die Temperatur von CPU, Mainboard und den Festplatten. Der auf sixserv.org laufende rbot(im Freenode idled der in #sixserv) soll auf Kommando den Status anzeigen. Soweit so gut. Ein kleines Ruby-Skript das auf dem Server zuhause läuft erfasst die [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_linux.png" width="50" height="51" alt="" title="Linux" /><br/><p>Ich wollte von unterwegs aus den Status meines Heimservers abrufen können. Dabei ging es mir vorallem um die Temperatur von CPU, Mainboard und den Festplatten. Der auf sixserv.org laufende rbot(im Freenode idled der in #sixserv) soll auf Kommando den Status anzeigen. Soweit so gut. Ein kleines Ruby-Skript das auf dem Server zuhause läuft erfasst die Temperaturen per &#8220;sensors&#8221; und &#8220;hddtemp&#8221;. Der xinetd-Daemon konfigurierte ich daraufhin so das auf einen Port das Skript gebunden wird. Es erwartet bevor es die Daten übermittelt ein Passwort, einfach zum zusätzlichen Schutz auch wenn das vielleicht gar nicht nötig ist. Jemand der einen Portscan durchführt könnte eben so informationen zum System gelangen, die Passwortabfrage verhindert dies.</p>
<p>Zunächst zu dem Ruby-Script(z.B. /opt/botinfo.rb):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
i = <span style="color:#CC00FF; font-weight:bold;">Kernel</span>.<span style="color:#CC0066; font-weight:bold;">gets</span>
<span style="color:#9966CC; font-weight:bold;">if</span> i.<span style="color:#CC0066; font-weight:bold;">chomp</span> != <span style="color:#996600;">'DASGEHEIMEPASSWORT'</span> <span style="color:#9966CC; font-weight:bold;">then</span>
	<span style="color:#008000; font-style:italic;"># puts 'Wrong Password'</span>
	<span style="color:#CC0066; font-weight:bold;">exit</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">`uptime`</span>.<span style="color:#9900CC;">lstrip</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># HDD Temps:</span>
matches = <span style="color:#996600;">`cat /proc/partitions`</span>.<span style="color:#9900CC;">scan</span> <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>s<span style="color:#006600; font-weight:bold;">|</span>h<span style="color:#006600; font-weight:bold;">&#93;</span>d<span style="color:#006600; font-weight:bold;">&#91;</span>a<span style="color:#006600; font-weight:bold;">-</span>z<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>
matches.<span style="color:#9900CC;">uniq</span>!
matches.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>disk<span style="color:#006600; font-weight:bold;">|</span>
	<span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#996600;">&quot;#{disk}: #{`hddtemp -n /dev/#{disk}`.chomp}.0*C (#{$1}GB) &quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> 
&nbsp;
systemp = <span style="color:#996600;">`sensors`</span>
&nbsp;
temp1 = systemp.<span style="color:#9900CC;">scan</span> <span style="color:#006600; font-weight:bold;">/</span>CPU Temp:    \<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.0.<span style="color:#9900CC;">C</span><span style="color:#006600; font-weight:bold;">/</span>
temp2 = systemp.<span style="color:#9900CC;">scan</span> <span style="color:#006600; font-weight:bold;">/</span>M\<span style="color:#006600; font-weight:bold;">/</span>B Temp:    \<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.0.<span style="color:#9900CC;">C</span><span style="color:#006600; font-weight:bold;">/</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;System: #{temp2[0]}.0*C #{temp2[1]}.0*C | CPUs: #{temp1[0]}.0*C #{temp1[1]}.0*C&quot;</span></pre></td></tr></table></div>

<p>Hier muss natürlich sensors und hddtemp installiert sein, aber dieses Script kann praktisch alles mögliche an Informationen sammeln und ausgeben.<br />
Die Konfiguration von xinetd gestaltet sich sehr einfach, in dem Verzeichnis /etc/xinetd.d einfach eine neue Datei für das Script erstellen(z.B. &#8220;botinfo&#8221;):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">service botinfo
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    disable         = no
    port            = <span style="color: #000000;">8888</span>
    socket_type     = stream
    protocol        = tcp
    <span style="color: #7a0874; font-weight: bold;">wait</span>            = no
    user            = apoc
    server          = <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>botinfo.rb
    <span style="color: #7a0874; font-weight: bold;">type</span>            = unlisted
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>Den Port, User und den Skript Pfad entsprechend anpassen und xinetd neu starten. Mit netcat kann es man danach testen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ nc localhost <span style="color: #000000;">8888</span>
DASGEHEIMEPASSWORT
<span style="color: #000000;">18</span>:<span style="color: #000000;">40</span>:<span style="color: #000000;">35</span> up <span style="color: #000000;">3</span> days, <span style="color: #000000;">41</span> min,  <span style="color: #000000;">4</span> <span style="color: #c20cb9; font-weight: bold;">users</span>,  load average: <span style="color: #000000;">0.00</span>, <span style="color: #000000;">0.02</span>, <span style="color: #000000;">0.20</span>
sda: <span style="color: #000000;">30.0</span><span style="color: #000000; font-weight: bold;">*</span>C <span style="color: #7a0874; font-weight: bold;">&#40;</span>10GB<span style="color: #7a0874; font-weight: bold;">&#41;</span> sdb: <span style="color: #000000;">29.0</span><span style="color: #000000; font-weight: bold;">*</span>C <span style="color: #7a0874; font-weight: bold;">&#40;</span>10GB<span style="color: #7a0874; font-weight: bold;">&#41;</span>
System: <span style="color: #000000;">39.0</span><span style="color: #000000; font-weight: bold;">*</span>C <span style="color: #000000;">38.0</span><span style="color: #000000; font-weight: bold;">*</span>C <span style="color: #000000; font-weight: bold;">|</span> CPUs: <span style="color: #000000;">37.0</span><span style="color: #000000; font-weight: bold;">*</span>C <span style="color: #000000;">36.0</span><span style="color: #000000; font-weight: bold;">*</span>C</pre></td></tr></table></div>

<p>Der Port muss ggf. vom Router geforwarded werden damit ein Entfernter Server darauf zugreifen kann. Auch ein dyndns ist hilfreich, sofern man über keine statische IP verfügt. Ein einfaches rbot-Plugin um diese Daten vom irc aus abzufragen sieht z.B. so aus:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'socket'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> BotinfoPlugin <span style="color:#006600; font-weight:bold;">&lt;</span> Plugin
  <span style="color:#9966CC; font-weight:bold;">def</span> help<span style="color:#006600; font-weight:bold;">&#40;</span>plugin, topic=<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#996600;">'info =&gt; return system information'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> info<span style="color:#006600; font-weight:bold;">&#40;</span>m, params<span style="color:#006600; font-weight:bold;">&#41;</span>
    sock = TCPSocket.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'heimserver.dyndns.org'</span>, <span style="color:#006666;">8888</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    sock.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'DASGEHEIMEPASSWORT'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    m.<span style="color:#9900CC;">reply</span> sock.<span style="color:#9900CC;">recv</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1024</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    sock.<span style="color:#9900CC;">close</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
plugin = BotinfoPlugin.<span style="color:#9900CC;">new</span>
plugin.<span style="color:#9900CC;">map</span> <span style="color:#996600;">'info'</span></pre></td></tr></table></div>

<p>Die Daten können ebenfalls von einem PHP-Script aus abgefragt werden. Keines Beispiel:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$socket</span> <span style="color: #339933;">=</span> <span style="color: #990000;">socket_create</span><span style="color: #009900;">&#40;</span>AF_INET<span style="color: #339933;">,</span> SOCK_STREAM<span style="color: #339933;">,</span> SOL_TCP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">socket_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$socket</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;heimserver.dyndns.org&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;8888&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DASGEHEIMEPASSWORT<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">socket_write</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$socket</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">socket_read</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$socket</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Vielleicht findet das ja irgendjemand interessant <img src='http://sixserv.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sixserv.org/2009/01/22/xinetd-info-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rbot Remote</title>
		<link>http://sixserv.org/2008/09/15/rbot-remote/</link>
		<comments>http://sixserv.org/2008/09/15/rbot-remote/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 21:14:48 +0000</pubDate>
		<dc:creator>apoc</dc:creator>
				<category><![CDATA[RBot]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[drb]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://sixserv.org/?p=90</guid>
		<description><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_ruby.png" width="50" height="51" alt="" title="Ruby" /><br/>Ich setze schon lange den grandiosen IRC-Bot &#8220;rbot&#8221; ein. Ein überaus vielseitiger und einfach zu erweiternder Bot, der dazu auch noch in meiner Lieblings Script-Sprache Ruby geschrieben ist. Vielleicht komme ich dazu einige meiner Plugins, die ich für ihn geschrieben habe, hier zu Veröffentlichen. Eines der Features von rbot welches ich erst kürzlich entdeckt habe [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/themes/6stheme/icons/icon_ruby.png" width="50" height="51" alt="" title="Ruby" /><br/><p>Ich setze schon lange den grandiosen IRC-Bot &#8220;<a href="http://ruby-rbot.org/">rbot</a>&#8221; ein. Ein überaus vielseitiger und einfach zu erweiternder Bot, der dazu auch noch in meiner Lieblings Script-Sprache <a href="http://www.ruby-lang.org/">Ruby</a> geschrieben ist. Vielleicht komme ich dazu einige meiner Plugins, die ich für ihn geschrieben habe, hier zu Veröffentlichen.</p>
<p>Eines der Features von rbot welches ich erst kürzlich entdeckt habe und was absolut genial ist, ist das <a href="http://ruby-rbot.org/rbot-trac/wiki/RbotRemote">Rbot Remote Interface</a>. Per Default hört der Bot nämlich auf Port 7268(127.0.0.1) und stellt dort ein <a href="http://segment7.net/projects/ruby/drb/">DRb(Distributed Ruby)</a> Interface zur Verfügung. Dieses erlaubt es von Außen den Bot zu steuern und beispielsweise Funktionen eines Plugins auszuführen. RbotRemote kann z.B. dazu genutzt werden bei neuen SVN-Commits im RSS Plugin das Updaten eines Commit-Feeds zu starten. Denkbar ist dies natürlich auch für neue Blog-Posts innerhalb von WordPress etc.</p>
<p>Da DRb logischerweise nur für Ruby zur Verfügung steht muss bspw. eine PHP-Webapplikation ein Ruby-Skript starten welches die gewünschte Aktionen am rbot auslöst. Hier als Beispiel-Skript wird eine Nachricht an #sixserv(btw: im Freenode) gesendet:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'drb'</span>
&nbsp;
rbot = DRbObject.<span style="color:#9900CC;">new_with_uri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;druby://localhost:7268&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
id = rbot.<span style="color:#9900CC;">delegate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">nil</span>, <span style="color:#996600;">&quot;remote login owner [Owner/Auth Passwort]&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:return</span><span style="color:#006600; font-weight:bold;">&#93;</span>
rbot.<span style="color:#9900CC;">delegate</span><span style="color:#006600; font-weight:bold;">&#40;</span>id, <span style="color:#996600;">&quot;dispatch say #sixserv Hallo Welt!&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>In <a href="http://ruby-rbot.org/rbot-trac/browser/bin/rbot-remote">/bin/rbot-remote</a> gibt es ein ähnliches, etwas komplexeres Beispiel welches die Eingaben von stdin erwartet.</p>
<p>Eine weitere Möglichkeit ist wie schon erwähnt eine Methode eines Plugins zu starten. Hier ein ganz einfaches rbot-(Remote)Plugin:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SimplePlugin <span style="color:#006600; font-weight:bold;">&lt;</span> Plugin
  <span style="color:#9966CC; font-weight:bold;">include</span> RemotePlugin
  <span style="color:#9966CC; font-weight:bold;">def</span> sayfoo<span style="color:#006600; font-weight:bold;">&#40;</span>m, params<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@bot</span>.<span style="color:#9900CC;">say</span> <span style="color:#996600;">'#sixserv'</span>, <span style="color:#996600;">'foo'</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> params.<span style="color:#9900CC;">has_key</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:bar</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
      <span style="color:#0066ff; font-weight:bold;">@bot</span>.<span style="color:#9900CC;">say</span> <span style="color:#996600;">'#sixserv'</span>, params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:bar</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
plugin = SimplePlugin.<span style="color:#9900CC;">new</span>
plugin.<span style="color:#9900CC;">remote_map</span> <span style="color:#996600;">'sayfoo'</span>
plugin.<span style="color:#9900CC;">remote_map</span> <span style="color:#996600;">'sayfoo :bar'</span></pre></div></div>

<p>Wird die Methode extern aufgerufen kann man natürlich kein m.reply verwenden, wenn die Nachricht im Channel landen soll, ich habe das hier ganz einfach gelöst indem ich den Channel fest eingebunden habe. Hier noch das Skript welches sayfoo mit Parameter aufruft:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'drb'</span>
&nbsp;
rbot = DRbObject.<span style="color:#9900CC;">new_with_uri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;druby://localhost:7268&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
id = rbot.<span style="color:#9900CC;">delegate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">nil</span>, <span style="color:#996600;">&quot;remote login owner [Owner/Auth Passwort]&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:return</span><span style="color:#006600; font-weight:bold;">&#93;</span>
rbot.<span style="color:#9900CC;">delegate</span><span style="color:#006600; font-weight:bold;">&#40;</span>id, <span style="color:#996600;">&quot;sayfoo bar&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Update: Das Plugin auf remote_map geändert, thanks for the hint tango!</p>
]]></content:encoded>
			<wfw:commentRss>http://sixserv.org/2008/09/15/rbot-remote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
