Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl Comparison with Bot::BasicBot( testing Equality )
    primarykey
    data
    text
    <p>I've figured it out it appears that I was testing each key individually and thats why it kept saying i wasn't in the Operators list.</p> <p>trick was to move the else statement out of foreach and to change it to a if statement.</p> <p>then a rather nasty hack inside the test for not equal</p> <p>original:</p> <pre><code>if($config-&gt;{'OP'}[$key] ne $message-&gt;{who}) </code></pre> <p>new: </p> <pre><code>if($config-&gt;{'OP'}[$key-1] ne $message-&gt;{who}) </code></pre> <p>final complete code:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; package kbot; use base qw(Bot::BasicBot); use YAML; use Data::Dumper; my $bot = kbot-&gt;new( server =&gt; 'irc.saurik.com', channels =&gt; ['#spam','#kbot'], nick =&gt; 'kbot',); sub reload{ system("perl kbot.pl"); } sub said { my ($self, $message) = @_; my $config = YAML::LoadFile('kelbot.yml'); if($message-&gt;{body} =~ 'reload'){ reload(); } if($message-&gt;{body} =~ 'opme'){ foreach $::key (keys $config-&gt;{OP}){ print $config-&gt;{OP}[$::key],"\n"; if($config-&gt;{OP}[$::key] eq $message-&gt;{who}){ $bot-&gt;mode($message-&gt;{channel}.' +o '.$message-&gt;{who}); } #end of if op } #end of foreach if($config-&gt;{OP}[$::key-1] ne $message-&gt;{who}){ $bot-&gt;say( channel =&gt; $message-&gt;{channel}, body =&gt; 'You aren\'t in the Operators list.', address =&gt; $message-&gt;{who}, ); } #end of optest } #end of opme } #end of said sub chanjoin { my ($self, $message) = @_; return 'kbot now online!'; } $bot-&gt;run(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload