Giter Club home page Giter Club logo

phergie-irc-client-react's Introduction

phergie-irc-client-react's People

Contributors

cboden avatar elazar avatar ericpoe avatar grachov avatar hason avatar igorw avatar jkazimir avatar matthewtrask avatar renegade334 avatar sitedyno avatar stil avatar svpernova09 avatar wyrihaximus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phergie-irc-client-react's Issues

Problem with I/O constants

I am making a web service that interfaces with some IRC stuff. When my script uses the phergie logging, it gives me Use of undefined constant STDERR - assumed 'STDERR'

It is clearly a problem with the lib being designed for CLI, so I looked into it further: http://php.net/manual/en/features.commandline.io-streams.php

Another potential problem can be found in the notes there: "These constants are not available if reading the PHP script from stdin."

While these aren't common use cases, I used this as a basic fix and it worked fine.

    if (!defined('STDERR'))
        define('STDERR', fopen('php://stderr', 'w'));

For compatibility, it would be nice to add this or an equivalent.

Missing "tick" event.

I think that Phergie client needs "tick" event. Without it, we cannot implement many time-based tools. Phergie 2 has such event and it is impossible to port plugins into new Phergie.

Exceptions should be replaced with "connect.error" events.

Today my bot crashed, because when it tried to reconnect, an exception occured.

PHP Fatal error:  Uncaught exception 'Phergie\Irc\Client\React\Exception' with message 'Unable to connect: socket error 110 Connection timed out' in /home/bot/bot/vendor/phergie/phergie-irc-client-react/src/Phergie/Irc/Client/React/Client.php:86

I think, that errors should be rather fired using events than exceptions. As the way it is, I'm not able to detect which connection crashed (and I have multiple connections).

Exception should be catched here, then we can emit "connect.error" event which could be easily handled.

unrecognized error in addSecureConnection

Hi guys,
i think here can be added some error handling/logging. Something like function ($e) { $this->logger->error($e->getMessage()); } can be very useful.

Currently i was not able detect problem with SecureConnector (in my case "Unable to complete SSL/TLS handshake: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed".

Thank your for your time, nice project!

ircWhois results in Notice and Warning

$queue->ircWhois('', 'hashworks');
PHP Warning:  Missing argument 2 for Phergie\Irc\Client\React\WriteStream::ircWhois() in phergie/phergie-irc-client-react/src/WriteStream.php on line 434
PHP Notice:  Undefined variable: nickmasks in phergie-irc-client-react/src/WriteStream.php on line 436

stream buffer (?) issue when using SSL

When I connect using SSL every last received message seems to be buffered and is only shown when the next message is received.

Can you confirm this?

<?php

require_once __DIR__ . '/vendor/autoload.php';

$connection = new \Phergie\Irc\Connection();

$connection->setServerHostname('chat.freenode.org');
$connection->setNickname('chickenbot');
$connection->setUsername('chickenbot');
$connection->setRealname('chickenbot');
$connection->setOption('transport', 'ssl');
$connection->setServerPort(7000);

$client = new \Phergie\Irc\Client\React\Client();
$client->run($connection);
2014-04-09 11:52:42 DEBUG :[email protected] JOIN #chickenbot
2014-04-09 11:52:42 DEBUG :dickson.freenode.net 353 chickenbot @ #chickenbot :chickenbot othillo
2014-04-09 11:52:42 DEBUG :dickson.freenode.net 366 chickenbot #chickenbot :End of /NAMES list.
2014-04-09 11:52:44 DEBUG :[email protected] PRIVMSG #chickenbot :1
2014-04-09 11:52:47 DEBUG :[email protected] PRIVMSG #chickenbot :2
11:52:38        --> | chickenbot ([email protected]) has joined #chickenbot
11:52:42    othillo | 1
11:52:42    othillo | 2
11:52:43    othillo | 3

QUIT handler in WriteStream results in the socket being closed before writing the QUIT command

The quit handler in WriteStream intends to write the command to the socket and then close the stream as follows:

$this->emit('data', array($msg));
$this->close();

On calling $this->close(), the 'end' event is thrown and the closure returned by Client::getEndCallback will mop up and close the socket stream. This occurs before the socket stream handles the send buffer, so the quit command is never sent to the server, and other IRC users will see a disconnect message saying that the client closed the socket, rather than seeing the intended quit message.

There needs to be some mechanism whereby the socket stream's send buffer is flushed before closing it.

DNS query error: too many retries

$connection = new Connection();
        $connection
            ->setServerHostname("irc.quakenet.org")
            ->setServerPort(6667)
            ->setNickname("test01010101010")
            ->setUsername("test10101010101")
            ->setOption('allow-self-signed', true)
        ;
        if ($this->config["ssl"])
            $connection->setOption('transport', 'ssl');

        $client = new Client();

        $client->on('irc.received', function ($message, $write, $conn, $logger) use ($io) {
            dump($message);
        });

        $client->run($connection);

leads to:
2017-03-05 15:32:24 ERROR DNS query for irc.quakenet.org failed: too many retries []

Is this an issue on my end?

Internal processing

I am working on a branch under Renegade334@devel-internal-processing that would give the client some input processing functionality in order to store or modify connection-specific data.

Examples of internal processing that the client absolutely should handle:

  • Calling Connection::setNickname() on receiving a NICK command from the server that corresponds to the connection
  • Responding to server PING messages

Examples that the client could handle:

  • Parsing RPL_ISUPPORT into a data array of server-supported parameters, plus mode and prefix maps
  • Parsing JOIN, MODE, PART, KICK, QUIT and RPL_NAMREPLY messages to compile and maintain internal channel lists
  • Parsing MODE messages to maintain a record of the client user's current user modes

Write stream in connect.after.each/all callback is always null

According to the documentation (and code) the connect.after.each callback should return the connection and the write stream belonging to it. The write stream seems to always be null. I'm pretty certain that it is a bug in the library. On this line getOption() gets called on the connection:

$this->emit('connect.after.each', array($connection, $connection->getOption('write')));
. I think it should be getData('write'). It gets set here:
$connection->setData('write', $write);
.

Calling $connection->getData('write') in my callback seems to yield the write stream like expected. :)

Missing "disconnected" event

I think it would be useful to have disconnected event.
Currently, the only way to catch disconnection is listening for ERROR message from IRC server (RFC 2812). Unfortunately, ERROR is used to report "serious problem" which doesn't always mean breaking the connection. Also, existing connect.error event doesn't fire when IRC server disconnects me.

Connecting to irc.rizon.sexy sometimes results in a registration timeout

This happens 1/10 times when you connect to the irc.rizon.sexy server:

2015-02-07 19:38:12 DEBUG [email protected] USER testident 0 * :testrn []
2015-02-07 19:38:12 DEBUG [email protected] NICK :testnick []
2015-02-07 19:38:12 DEBUG [email protected] :irc.rizon.sexy NOTICE AUTH :*** Found your hostname (cached) []
2015-02-07 19:38:12 DEBUG [email protected] :irc.rizon.sexy NOTICE AUTH :*** Checking Ident []
2015-02-07 19:38:14 DEBUG [email protected] :irc.rizon.sexy NOTICE AUTH :*** No Ident response []
2015-02-07 19:38:49 DEBUG [email protected] PING :2937740994 []
2015-02-07 19:38:49 DEBUG [email protected] PONG :2937740994 []
2015-02-07 19:38:49 DEBUG [email protected] ERROR :Closing Link: mnch-5d86ba90.pool.mediaWays.net (Registration timed out) []

As you see the PING arrives when the server closes the connection - way too late.

I had the same problem with this server before when developing on my own IRC bots - however my mistake was that I used \n\r instead of \r\n, according to the parser this doesn't seem to be the issue. In my case the PING message rested in the buffer until the ERROR arrvied.

I'm not sure if this is a parsing problem, so I'm posting this here.

Missing package on Packagist

There is no phergie-irc-client-react on Packagist.
Please add service hook, so we can install it through composer without adding additional parameters in configuration.

Clarify how to use `addListener`

Hi,

I'm looking to implement a simple IRC logger on top of phergie-irc-client-react.

So that I can keep connected, I've tried implemented PingPong and Auto-join, that way:

$client->addListener(function($message, $write, $connection, $logger) {
    // Ping Pong:
    if ($message['command'] === 'PING') {
        $write->ircPong('my-daemon-irclogs');
    }

    // Auto-join:
    if (isset($message['code']) && in_array($message['code'], array('RPL_ENDOFMOTD', 'ERR_NOMOTD'))) {
        $write->ircJoin('#phergie');
    }
});

However, I can join the channel, but then I don't get PING commands. Additionnally, I'm not seeing any messages with actual posted content from any channel.

Any idea what I'm doing wrong here?

Best,

Julien

Troubles on reattached connections to Client

Last days I have big troubles with stability of my IRC bots.
To detect broken connection, I compare last ping times. When last ping from IRC server was long time ago, I try to reattach the connection to Client using:

$client->addConnection($brokenConnection);

However, it's very dangerous operation, because Client can double the events. Finally, it can end up with events fired multiple times on single IRC message:

<me> .time
<bot> 12:50
<bot> 12:50
<bot> 12:50
<bot> 12:50
<bot> 12:50

The solution would be detecting reattached connection on Client and resetting event listeners.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.