1 ;;; zenirc-fortran.el --- emulate F-BOT FORTRAN bot program with ZenIRC
3 ;; Copyright (C) 1993, 1994 Ben A. Mesander
4 ;; Copyright (C) 1997 Noah Friedman
6 ;; Author: Ben A. Mesander <ben@gnu.ai.mit.edu>
7 ;; Maintainer: ben@gnu.ai.mit.edu
8 ;; Keywords: extensions
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
28 ;; Example hook code to override something internal to zenirc.
29 ;; Also a good example of a server message hook.
31 ;; From ben@gnu.ai.mit.edu Tue May 11 08:12:27 1993
32 ;; Newsgroups: alt.irc
33 ;; From: ben@gnu.ai.mit.edu (Ben A. Mesander)
34 ;; Subject: Re: introducing ZENBOT 1.0!!!! (Bot-lovers)
35 ;; Summary: FORTRAN BOTZ RULE!!!!!!111
36 ;; In-Reply-To: christian@hopper.Virginia.EDU's message of Mon, 10 May 1993 23:43:42 GMT
37 ;; Date: Tue, 11 May 1993 04:44:42 GMT
38 ;; Nntp-Posting-Host: gnu.ai.mit.edu
39 ;; Organization: The phedz.
43 ;; ircII bots are for weenies. Even C bots are slow on supercomputer
44 ;; architectures. On a Cray, FORTRAN is much faster than C, due to the
45 ;; architecture of the machine. Therefore I - piglet3 - the GENIUS
46 ;; MASTERMIND of IRC have written a FORTRAN bot. This bot is guaranteed
47 ;; to be faster than any C bot if run on a Cray II or above. I am sure
48 ;; the irCOPS want to keep this technology secret, but I - piglet3 - am
49 ;; going to reveal the SECRET OF FAST BOTS ON IRC RIGHT IN THIS POSTING!
51 ;; Unlike Christian's RESTRICTIVE licensing agreement, my bot is in the
52 ;; PUBLIC DOMAIN! If you want to use it and claim you wrote it, PLEASE DO!
54 ;; The source comes in three files, a Makefile (yes, Christian's bot had
55 ;; NO MAKEFILE! IT WAS HARD TO INSTALL!), a FORTRAN source code file, and
56 ;; a small C code interface to the UNIX operating system. Those of you
57 ;; running operating systems besides UNIX should have no trouble writing
58 ;; the network interface routines in FORTRAN instead of C.
60 ;; Future releases of this program will be installable via GNU Configure,
61 ;; thus making installation even easier. The FORTRAN-C calling interface
62 ;; is assumed to be BSD-style, for those of you who really want to compile
65 ;; ---Makefile---cut here---
70 ;; $(F77) bot.o sock.o -o bot
77 ;; ---bot.f---cut here---
78 ;; CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
80 ;; C FORTRAN BOT PROGRAM FOR IRC II
83 ;; C BEN@GNU.AI.MIT.EDU
85 ;; C THIS PROGRAM IS IN THE PUBLIC DOMAIN
86 ;; CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
89 ;; CHARACTER*80 SERVER, CHANEL, NICK, NAME, USER, HOST
91 ;; C YOU MUST CUSTOMIZE THESE VARIABLES
93 ;; NAME='EXPERIMENTAL FORTRAN IRC-II BOT PROGRAM'
95 ;; HOST='GNU.AI.MIT.EDU'
97 ;; PRINT *,'ENTER NAME OF IRC-SERVER TO USE:'
98 ;; READ(*,'(A)') SERVER
99 ;; PRINT *,'ENTER NAME OF CHANNEL TO JOIN:'
100 ;; READ(*,'(A)') CHANEL
104 ;; PRINT *,'UNABLE TO CONNECT TO IRC-SERVER'
108 ;; I=WRSOCK('NICK '//NICK)
110 ;; PRINT *,'UNABLE TO WRITE IRC-NICK TO SERVER'
114 ;; I=WRSOCK('USER '//USER(1:INDEX(USER,' ')-1)//'@'//HOST(1:
115 ;; + INDEX(HOST,' ')-1)//' 1 1 :'//NAME)
117 ;; PRINT *,'UNABLE TO WRITE IRC-NAME TO SERVER'
122 ;; CALL BOTTY(CHANEL,NICK,USER,HOST)
127 ;; SUBROUTINE EATMTD()
128 ;; C PURPOSE - TO EAT THE MOTD
129 ;; CHARACTER*513 INLINE
134 ;; PRINT *,'ERROR WHILE READING MOTD'
137 ;; IF ((INDEX(INLINE,'End of /MOTD').EQ.0).OR.
138 ;; + (INDEX(INLINE,'376').NE.0)) GOTO 10
142 ;; SUBROUTINE BOTTY(CHANEL, NICK, USER, HOST)
143 ;; CHARACTER*80 CHANEL, NICK, USER, HOST
144 ;; C PURPOSE - TO BE BOTTY
145 ;; CHARACTER*513 INLINE
147 ;; I=WRSOCK('JOIN '//CHANEL)
149 ;; PRINT *,'ERROR WHILE JOINING CHANNEL'
157 ;; PRINT *,'ERROR READING FROM IRC-SERVER'
161 ;; IF (INDEX(INLINE,'PING').EQ.1) THEN
162 ;; I=WRSOCK('PONG '//HOST)
164 ;; PRINT *,'ERROR WHILE PONGING'
170 ;; IF (INDEX(INLINE,'FORTRAN').NE.0) THEN
171 ;; I=WRSOCK('PRIVMSG '//CHANEL(:INDEX(CHANEL,' ')-1)//
172 ;; + ' :YES I AM REALLY WRITTEN IN 3L33T FORTRAN-77!!!!!!!')
174 ;; PRINT *,'ERROR WRITING 3L33T MESSAGE TO IRC-SERVER'
180 ;; IF (INDEX(INLINE,'PHONE IS A SLUT').NE.0) RETURN
186 ;; ---sock.c---cut here---
188 ;; * rudimentary C socket I/O routines for FORTRAN bot.
191 ;; * ben@gnu.ai.mit.edu
193 ;; * this code is in the public domain
196 ;; #include <stdio.h>
197 ;; #include <sys/types.h>
198 ;; #include <sys/socket.h>
199 ;; #include <netinet/in.h>
200 ;; #include <netdb.h>
201 ;; #define IRCPORT 6667
203 ;; int sock; /* socket to connect to server */
206 ;; * open a socket to the irc server on "hostname"
209 ;; int opsock_(char *fhostname, int fhostnamelen)
213 ;; struct sockaddr_in addr;
214 ;; struct hostent *h;
216 ;; if (NULL == (hostname = (char *)malloc(fhostnamelen+1))) {
219 ;; strncpy(hostname, fhostname, fhostnamelen+1);
220 ;; for(i=0;i<strlen(hostname);i++) {
221 ;; if (' ' == *(hostname+i)) {
222 ;; *(hostname+i)='\0';
227 ;; if (NULL == (h = gethostbyname(hostname))) {
230 ;; addr.sin_family = AF_INET;
231 ;; addr.sin_port = IRCPORT;
232 ;; bcopy(h->h_addr, (char *)&addr.sin_addr, h->h_length);
233 ;; bzero((char *)addr.sin_zero, sizeof(addr.sin_zero));
235 ;; if ( 0 > (sock = socket(AF_INET, SOCK_STREAM, 0))) {
239 ;; if ( 0 > connect(sock, &addr, sizeof(addr))) {
251 ;; int rdsock_(char *buf, int buflen)
255 ;; for (i=0; i<513; i++) {
256 ;; if (1 != read(sock,buf+i,1)) {
259 ;; if ('\n' == *(buf+i)) {
266 ;; int wrsock_(char *buf, int buflen)
270 ;; for (i=0; i<buflen; i++) {
271 ;; if (1 != write(sock, buf+i, 1)) {
275 ;; if (1 != write(sock, "\n", 1)) {
284 ;; ben@gnu.ai.mit.edu
287 ;; Thanks to zenirc-trigger.el, this elisp module has been reduced to a
288 ;; one-liner, but the real live fortran above is too eleet to stop
293 (require 'zenirc-trigger)
295 (zenirc-trigger-register "fortran"
296 "YES I AM REALLY WRITTEN IN 3L33T FORTRAN 77!!!!!!!!!111"
299 (provide 'zenirc-fortran)
301 ;; zenirc-fortran.el ends here