Commit c4b4a7884ccb6c847cd557e3133e392b0141fd33
- Diff rendering mode:
- inline
- side by side
def/EightBall.def
(7 / 0)
|   | |||
| 1 | DEFINITION MODULE EightBall; | ||
| 2 | |||
| 3 | IMPORT Message; | ||
| 4 | |||
| 5 | PROCEDURE EightBall(parse: Message.Parse); | ||
| 6 | |||
| 7 | END EightBall. |
obj/Handler.o
(65 / 62)
Binary files differ
obj/Mention.o
(28 / 29)
Binary files differ
obj/gaze.o
(27 / 25)
Binary files differ
obj/m.o
(24 / 20)
Binary files differ
obj/p6Fifo.o
(5 / 3)
Binary files differ
obj/t.o
(2 / 2)
Binary files differ
obj/u.o
(4 / 4)
Binary files differ
obj/users.o
(28 / 23)
Binary files differ
obj/w.o
(6 / 7)
Binary files differ
src/EightBall.mod
(66 / 0)
|   | |||
| 1 | IMPLEMENTATION MODULE EightBall; | ||
| 2 | |||
| 3 | FROM RandCard IMPORT RandInt, seed; | ||
| 4 | FROM TimeConv IMPORT millisecs; | ||
| 5 | IMPORT Message, FormStr; | ||
| 6 | |||
| 7 | PROCEDURE EightBall(parse: Message.Parse); | ||
| 8 | VAR | ||
| 9 | result : Message.strType; | ||
| 10 | answers : ARRAY [0..42] OF ARRAY [0..29] OF CHAR; | ||
| 11 | choice : INTEGER; | ||
| 12 | BEGIN | ||
| 13 | seed := millisecs(); (* re-seed the random number generator *) | ||
| 14 | (* There is probably a better way of doing this *) | ||
| 15 | answers[0] := 'Yes.'; | ||
| 16 | answers[1] := 'No.'; | ||
| 17 | answers[2] := 'Outlook not so good.'; | ||
| 18 | answers[3] := 'All signs point to yes.'; | ||
| 19 | answers[4] := 'All signs point to no'; | ||
| 20 | answers[5] := 'Ask again later.'; | ||
| 21 | answers[6] := 'The answer is unclear.'; | ||
| 22 | answers[7] := 'A definite maybe.'; | ||
| 23 | answers[8] := 'Signs point to yes.'; | ||
| 24 | answers[9] := 'Yes.'; | ||
| 25 | answers[10] := 'Reply hazy, try again.'; | ||
| 26 | answers[11] := 'Without a doubt.'; | ||
| 27 | answers[12] := 'My sources say no.'; | ||
| 28 | answers[13] := 'As I see it, yes.'; | ||
| 29 | answers[14] := 'You may rely on it.'; | ||
| 30 | answers[15] := 'Concentrate and ask again.'; | ||
| 31 | answers[16] := 'Outlook not so good.'; | ||
| 32 | answers[17] := 'It is decidedly so.'; | ||
| 33 | answers[18] := 'Better not tell you now.'; | ||
| 34 | answers[19] := 'Very doubtful.'; | ||
| 35 | answers[20] := 'Yes - definitely.'; | ||
| 36 | answers[21] := 'It is certain.'; | ||
| 37 | answers[22] := 'Cannot predict now.'; | ||
| 38 | answers[23] := 'Most likely.'; | ||
| 39 | answers[24] := 'Ask again later.'; | ||
| 40 | answers[25] := 'My reply is no.'; | ||
| 41 | answers[26] := 'Outlook good.'; | ||
| 42 | answers[27] := "Don't count on it"; | ||
| 43 | answers[28] := 'Yes, in due time.'; | ||
| 44 | answers[29] := 'My sources say no.'; | ||
| 45 | answers[30] := 'Definitely not.'; | ||
| 46 | answers[31] := 'Yes.'; | ||
| 47 | answers[32] := 'You will have to wait.'; | ||
| 48 | answers[33] := 'I have my doubts.'; | ||
| 49 | answers[34] := 'Outlook so so.'; | ||
| 50 | answers[35] := 'Looks good to me!'; | ||
| 51 | answers[36] := 'Who knows?'; | ||
| 52 | answers[37] := 'Looking good!'; | ||
| 53 | answers[38] := 'Probably.'; | ||
| 54 | answers[39] := 'Are you kidding?'; | ||
| 55 | answers[40] := 'Go for it!'; | ||
| 56 | answers[41] := "Don't bet on it."; | ||
| 57 | answers[42] := 'Forget about it.'; | ||
| 58 | |||
| 59 | choice := RandInt(0, 42); | ||
| 60 | FormStr.print(result, "%s shakes the magic 8-ball... %s", parse.botname, answers[choice]); | ||
| 61 | Message.PrintLine(parse.chan, result); | ||
| 62 | EXCEPT | ||
| 63 | RETURN | ||
| 64 | END EightBall; | ||
| 65 | |||
| 66 | END EightBall. |
src/Handler.mod
(5 / 2)
|   | |||
| 48 | 48 | IMPORT users; | |
| 49 | 49 | IMPORT WholeStr, RegComp, FormStr; | |
| 50 | 50 | ||
| 51 | IMPORT b, d, c, f, google, k, m, Mention, n, o, p, q, r, s, t, u, v, w; | ||
| 51 | IMPORT b, d, c, EightBall, f, google, k, m, Mention, n, o, p, q, r, s, t, u, v, w; | ||
| 52 | 52 | IMPORT Timers, tracker, bugcheckState, bugsearch, conversions, util; | |
| 53 | 53 | FROM Setup IMPORT ChannelT, checkChans, check; | |
| 54 | 54 | ||
| … | … | ||
| 282 | 282 | cmd := parse.cmd; | |
| 283 | 283 | Capitalize(cmd); | |
| 284 | 284 | ||
| 285 | |||
| 285 | (* Misc *) | ||
| 286 | (* 8 <><><><><><><><><><> *) | ||
| 287 | (* 8ball - Magic 8-ball *) | ||
| 288 | IF Left("8BALL", cmd) OR Left("8-BALL", cmd) THEN EightBall.EightBall(parse) END; | ||
| 286 | 289 | (* A <><><><><><><><><><> *) | |
| 287 | 290 | (* B <><><><><><><><><><> *) | |
| 288 | 291 | (* Backup - back up the program source to timestorm (will later backup settings files) *) |
src/Mention.mod
(0 / 11)
|   | |||
| 213 | 213 | BEGIN | |
| 214 | 214 | alreadyFound := mentionFound; | |
| 215 | 215 | (* Second loop. Process entire log, if mentionFound=FALSE, do search, otherwise just transfer matches *) | |
| 216 | (* IF NOT mentionFound THEN (* Process returned FALSE, checking whole log *); *) | ||
| 217 | 216 | FormStr.print (command, "tac %s/log/irclog | grep -i '%s' > %stemporary.log", p6datPath, string, p6tmpPath); | |
| 218 | 217 | status := ProgExec.Command(command, exit); | |
| 219 | 218 | ||
| … | … | ||
| 235 | 235 | ELSE | |
| 236 | 236 | output(out, "No mentions were found"); | |
| 237 | 237 | END; | |
| 238 | (* | ||
| 239 | IF mentionFound AND NOT FileSys.Exists(p6tmpPath+"alreadyFound") THEN | ||
| 240 | Message.PrintLine(line.chan, outputStr); | ||
| 241 | output(out, outputStr); | ||
| 242 | SeqFile.OpenWrite(file, p6tmpPath+"alreadyFound", writeFlags, iores); | ||
| 243 | TextIO.WriteString(file, "found"); | ||
| 244 | SeqFile.Close(file); | ||
| 245 | END; | ||
| 246 | *) | ||
| 247 | 238 | HALT; | |
| 248 | 239 | ELSE | |
| 249 | 240 | END; | |
| 250 | |||
| 251 | 241 | ||
| 252 | 242 | END SecondStep; | |
| 253 | 243 |
src/gaze.mod
(2 / 1)
|   | |||
| 147 | 147 | modDepends = "| sed s/\(depends\)//g "; (* modify (depends) *) | |
| 148 | 148 | modOptional = "| sed s/\ \(optional\)/*/g "; (* Modify (optional) *) | |
| 149 | 149 | modSub = "| sed s/-sub//g "; (* Modify -sub *) | |
| 150 | FILTER = noColors+modDepends+modOptional+modSub; | ||
| 150 | modSpaces = "| sed 's/^ *//;s/ *$//;s/ \{1,\}/ /g' "; (* delete extra spaces *) | ||
| 151 | FILTER = noColors+modDepends+modOptional+modSub+modSpaces; | ||
| 151 | 152 | ||
| 152 | 153 | writeFIFO = p6Fifo.writeFIFO; | |
| 153 | 154 | readFIFO = p6Fifo.readFIFO; |
src/p6Fifo.mod
(3 / 4)
|   | |||
| 22 | 22 | stat.mkfifo(fifoName, 777B); | |
| 23 | 23 | END; | |
| 24 | 24 | FormStr.append(command, " > %s &", fifoName); | |
| 25 | Done := ProgExec.Command(command, return); | ||
| 25 | done := ProgExec.Command(command, return); | ||
| 26 | 26 | END writeFIFO; | |
| 27 | 27 | ||
| 28 | 28 | PROCEDURE readFIFO(VAR string : ARRAY OF CHAR); | |
| … | … | ||
| 30 | 30 | found : BOOLEAN; | |
| 31 | 31 | pos : CARDINAL; | |
| 32 | 32 | BEGIN | |
| 33 | buffer := ""; | ||
| 34 | Strings.Assign("", string); | ||
| 33 | buffer := ""; Strings.Assign("", string); | ||
| 35 | 34 | pipeFd := fcntl.open(fifoName, openRead); | |
| 36 | 35 | IF (pipeFd <> -1) THEN | |
| 37 | 36 | REPEAT | |
| … | … | ||
| 51 | 51 | bufAdr := string.memset(buffer, 0, SIZE(buffer)); | |
| 52 | 52 | ||
| 53 | 53 | FINALLY | |
| 54 | FileSys.Remove(fifoname, done); | ||
| 54 | FileSys.Remove(fifoName, done); | ||
| 55 | 55 | END p6Fifo. |
src/u.mod
(4 / 4)
|   | |||
| 14 | 14 | ||
| 15 | 15 | IMPLEMENTATION MODULE u; | |
| 16 | 16 | ||
| 17 | IMPORT FileSys, Message, ProgExec, StreamFile, Strings, TextIO, IOResult, util; | ||
| 17 | IMPORT FileSys, Message, ProgExec, StreamFile, Strings, TextIO, IOResult, util, p6Fifo; | ||
| 18 | 18 | ||
| 19 | 19 | PROCEDURE Uptime(parse : Message.Parse); | |
| 20 | 20 | (* Uptime: How long has the computer that the bot is running on *) | |
| … | … | ||
| 26 | 26 | iores : StreamFile.OpenResults; | |
| 27 | 27 | file : StreamFile.ChanId; | |
| 28 | 28 | BEGIN | |
| 29 | util.CmdUsed(parse); | ||
| 29 | util.CmdUsed(parse); | ||
| 30 | 30 | exit := 0; result := ""; str := ""; | |
| 31 | 31 | done := ProgExec.Command("uptime > /home/terry/p6dat/tmp/uptime", exit); | |
| 32 | 32 | StreamFile.Open(file, "/home/terry/p6dat/tmp/uptime", StreamFile.read, iores); | |
| … | … | ||
| 34 | 34 | TextIO.SkipLine(file); | |
| 35 | 35 | StreamFile.Close(file); | |
| 36 | 36 | FileSys.Remove("/home/terry/p6dat/tmp/uptime",done); | |
| 37 | Strings.Assign("Uptime: ",str); | ||
| 38 | Strings.Concat(str, result, str); | ||
| 37 | Strings.Assign("Uptime: ",str); | ||
| 38 | Strings.Concat(str, result, str); | ||
| 39 | 39 | Message.PrintLine(parse.chan, result); | |
| 40 | 40 | END Uptime; | |
| 41 | 41 |
src/users.mod
(10 / 8)
|   | |||
| 26 | 26 | ||
| 27 | 27 | CONST | |
| 28 | 28 | debugging = FALSE; | |
| 29 | tempfile = "/usr/share/httpd/htdocs/users/temp.png"; (* old file, used with diff command *) | ||
| 30 | difffile = "/usr/share/httpd/htdocs/users/visual-diff.pam"; (* graphic output *) | ||
| 31 | difftext = "/usr/share/httpd/htdocs/users/visual-diff.txt"; (* readable output *) | ||
| 32 | notefile = "/usr/share/httpd/htdocs/users/note"; (* file for email *) | ||
| 29 | webDir = '/usr/local/www/server/page6.shlrm.org/pages/'; | ||
| 30 | |||
| 31 | tempfile = webDir+"users/temp.png"; (* old file, used with diff command *) | ||
| 32 | difffile = webDir+"users/visual-diff.pam"; (* graphic output *) | ||
| 33 | difftext = webDir+"users/visual-diff.txt"; (* readable output *) | ||
| 34 | notefile = webDir+"users/note"; (* file for email *) | ||
| 33 | 35 | ||
| 34 | 36 | PROCEDURE generateImage(lat, long : REAL; rad : CARDINAL; name : ARRAY OF CHAR; parse: Message.Parse): Message.strType ; | |
| 35 | 37 | VAR | |
| … | … | ||
| 63 | 63 | ** or: pamarith -difference <(pngtopnm smgl-us.png) <(pngtopnm smgl-us-nov06.png) | pamsumm -maxx > file | |
| 64 | 64 | *) | |
| 65 | 65 | ||
| 66 | file := "/usr/share/httpd/htdocs/users/smgl-FN.png"; (* new file for potential upload to Flickr *) | ||
| 66 | file := webDir+"users/smgl-FN.png"; (* new file for potential upload to Flickr *) | ||
| 67 | 67 | StringParse.Replace(file, "FN", name); | |
| 68 | 68 | filepng := file; | |
| 69 | 69 | ||
| … | … | ||
| 74 | 74 | ** really works in relation to images created after I changed to this method. | |
| 75 | 75 | ** create the file note, which will contain the description and tags | |
| 76 | 76 | *) | |
| 77 | command := "echo 'Source Mage GNU/Linux users centered over NAME DATE TIME http://www.sourcemage.org tags: smgl users' > /usr/share/httpd/htdocs/users/note"; | ||
| 77 | command := "echo 'Source Mage GNU/Linux users centered over NAME DATE TIME http://www.sourcemage.org tags: smgl users' > /usr/local/www/servers/page6.shlrm.org/pages/users/note"; | ||
| 78 | 78 | StringParse.Replace(command, "NAME", name); | |
| 79 | 79 | StringParse.Replace(command, "DATE", util.Date(parse)); | |
| 80 | 80 | StringParse.Replace(command, "TIME", util.Time(parse)); | |
| 81 | 81 | done := ProgExec.Command(command, res); | |
| 82 | command := "mail -s 'smgl users in NAM' -a FILE eight06looked@photos.flickr.com < /usr/share/httpd/htdocs/users/note"; | ||
| 82 | command := "mail -s 'smgl users in NAM' -a FILE eight06looked@photos.flickr.com < /usr/local/www/servers/page6.shlrm.org/pages/users/note"; | ||
| 83 | 83 | StringParse.Replace(command, "FILE", filepng); | |
| 84 | 84 | StringParse.Replace(command, "NAM", name); | |
| 85 | 85 | IF debugging THEN | |
| … | … | ||
| 100 | 100 | ** compare -metric AE | |
| 101 | 101 | ** this is done by a bash script in the directory, and creates the file visual-diff.txt | |
| 102 | 102 | *) | |
| 103 | command := '/usr/share/httpd/htdocs/users/test.sh "PNGf"'; | ||
| 103 | command := '/usr/local/www/servers/page6.shlrm.org/pages/users/test.sh "PNGf"'; | ||
| 104 | 104 | StringParse.Replace(command, "PNGf", filepng); | |
| 105 | 105 | IF debugging THEN | |
| 106 | 106 | Message.Notice("qnr", command); |
src/w.mod
(3 / 2)
|   | |||
| 85 | 85 | target := str; (* get rid of the the formatting changes *) | |
| 86 | 86 | (* Check string for Humidity, or Current, if it's there, then the return is valid *) | |
| 87 | 87 | IF StringParse.InString("Humidity", result) THEN | |
| 88 | (* Error in my code somewhere isn't clearing the previous line, so I'm | ||
| 88 | (* Error in my code somewhere. It isn't clearing the previous line returned, so I'm | ||
| 89 | 89 | manually trimming everything after the %. Must be in the FIFO, but I can't see where. *) | |
| 90 | 90 | Strings.FindNext("%", result, 0, found, pos); | |
| 91 | 91 | IF found THEN Strings.Delete(result, pos+1, LENGTH(result)) END; | |
| … | … | ||
| 93 | 93 | ELSE | |
| 94 | 94 | FormStr.print(str, "I'm sorry, I couldn't find any weather for %s", target); | |
| 95 | 95 | END; | |
| 96 | |||
| 97 | 96 | Message.PrintLine(parse.chan, str); | |
| 98 | 97 | EXCEPT | |
| 98 | (* Flesh this out, find out what the exceptions are and write code to keep | ||
| 99 | them from occurring *) | ||
| 99 | 100 | Message.PrintLine(parse.chan, "For what location?"); | |
| 100 | 101 | RETURN; | |
| 101 | 102 | END Weather; |
sym/w.sym
(9 / 3)
Binary files differ
tmp.mkf
(2 / 0)
|   | |||
| 22 | 22 | ||
| 23 | 23 | OBJ= \ | |
| 24 | 24 | obj/Connect.o \ | |
| 25 | obj/EightBall.o \ | ||
| 25 | 26 | obj/FloodProtect.o \ | |
| 26 | 27 | obj/Handler.o \ | |
| 27 | 28 | obj/Logging.o \ | |
| 28 | 29 | obj/Mention.o \ | |
| 29 | 30 | obj/Message.o \ | |
| 30 | 31 | obj/PageSix.o \ | |
| 32 | obj/RandCard.o \ | ||
| 31 | 33 | obj/Setup.o \ | |
| 32 | 34 | obj/Stack.o \ | |
| 33 | 35 | obj/StringParse.o \ |

