
pcweirdo wrote:jimie, the ones on SourceForge are pre-alpha at best, but you can steal code to get you started. I started on one but my comrades and I couldn't get a free web host that had the right conditions. Trawling through free web hosting listings on the Internet testing them is a pain in the arse.
http://users.on.net/~conheady/patbot.tar.gz is my code. It's partially functional; let me know what you think of the coding style and the commenting.
Basically, the blocker I ran into was that many PHP installations set a time limit of, say, 30 seconds, for a script to run. This is to stop bad code spawning never-ending loops, which just chew CPU time and waste money.
It also means that your bot will connect to the channel for a grand total of 30 seconds before it is killed.
You need a web host where either
a) there is no time limit
b) you can change the relevant INI setting in your PHP code. The name of this setting is buried in the PHP manual.
Another concern is the firewall on the web server. The web server might be blocked from making outgoing connections, or even specifically IRC might be blocked.
Alternatively, the firewall might be very relaxed, and you might be able to bind listening sockets from within PHP code. This would allow you to run, for example, an IRC server.
If you can get it working, it is extremely useful. It provides another IP address to connect to servers from (good for avoiding bans and clone limits), and doesn't affect your process count on any shell accounts. Plus, web hosting is probably easier to get anonymously from many sources simultaneously than shell accounts. More people give out web hosting than shell accounts.
An IRC bot is one thing, but if that works, hack up an SSH server, a proxy and more, all running in PHP.
As yet another approach you might take, you could use backticks to run binaries on your web server. This way, you could run eggdrop! Again, this is subject to countless restrictions by PHP and the server, and I can't even describe which parts of the fair usage agreements you might break.
Backticks also have the advantage that if the PHP script timeout is your only obstacle, backgrounding a shell script (or a PHP script through the CGI or CLI PHP binaries) will often allow you to run code all day.
OP, to make multiple connections with the one process (I rudely assume you're trying to circumvent the shell account process limit), you might need to edit some code yourself. Threads might be what you are after, but I'm not sure how multithreading interacts with the process limit. Editing code can be messy, but if you'll feel really good if you introduce new and useful functionality to an open-source product.
-pcweirdo.
set_time_limit(0);

That's a handy bit of information, when the site administrator hasn't set a web server time limit.bart416 wrote:Uhm you mean the execution time limit that you can set within the script
- Code: Select all
set_time_limit(0);
Should do the trick...
O rly? When you have a certain server, and that server will not allow you to run code except PHP code, what would you do instead?bart416 wrote:But PHP is not fit for IRC bots

koncept wrote:Does anyone know a irc script (bot) that once you connect on a channel make like your are 3 user connect or more on the channel.
Make several connection with only one process?
blinker wrote:do anyone know some links or where can i get free mrc proxy?


pcweirdo wrote:That's a handy bit of information, when the site administrator hasn't set a web server time limit.bart416 wrote:Uhm you mean the execution time limit that you can set within the script
- Code: Select all
set_time_limit(0);
Should do the trick...O rly? When you have a certain server, and that server will not allow you to run code except PHP code, what would you do instead?bart416 wrote:But PHP is not fit for IRC bots
PHP is horrible for coding IRC bots, which is why almost nobody does it. But using PHP does open up more possibilities.
-pcweirdo.

PHP doesn't generally leak memory in loops, by virtue of its garbage collection. Of course, the PHP programmer/scripter/coder/waiter still needs to make sure they aren't accumulating huge dynamic arrays or something.bart416 wrote:You will force PHP into an endless loop.
That will cause serious memory usage and the bot will needed to be restarted several times / day. Unless you set the memory limit to an insane high value.
An endless loop (which often isn't endless, since facilities such as the break command are available) is commonly employed by software ranging from games, network servers and the Linux kernel. It is a convenient away to run a "main loop" that runs again and again, each time with new input from the user or the network. Is that so stupid?bart416 wrote:Basically the script just puts its code in:
while(1) {} tags in most cases.
Thats just plain stupid in fact.
while(!feof($irc_sock)) // (where $irc_sock is a socket connected to a remote server)while(1)
set_time_limit(0);

chiron wrote:most shared hosting will have safe_mode enabled on php and so therefore
- Code: Select all
set_time_limit(0);
will be restricted, however you could still run a bot for 30 seconds or < max execution time.



blinker wrote:hmm.. nice topic.hmm.. do anyone know some links or where can i get free mrc proxy?

Users browsing this forum: No registered users and 1 guest