From 532259cdadcab1f910ecb0531f43824590a4ea63 Mon Sep 17 00:00:00 2001 From: Sean Hinchee Date: Mon, 30 Apr 2018 17:36:13 +0000 Subject: [PATCH] working on manmatch --- README.md | 5 +++++ TODO | 10 ++++++---- rebuild | 4 ++++ x/mux/lookman/lookman | 2 +- x/mux/man.go | 7 ++++++- x/mux/man/matchman | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 6 deletions(-) create mode 100755 rebuild create mode 100755 x/mux/man/matchman diff --git a/README.md b/README.md index f395167f6d9951066a87193c03fa3494509a875b..227ef5c25cc06b820e6b09584b6bb7b8b944594a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Dis**go**rd is an example of or starting point for creating an easy to use and extensible Discord bot using the [DiscordGo](https://github.com/bwmarrin/discordgo) library. +### Dependencies + +* Go +* Lookman functionality relies on [plan9port](https://github.com/9fans/plan9port) and a mirror of the 9front manuals/source + ### Installing ``` diff --git a/TODO b/TODO index f7ff7e4701e9616837824cf9b16d8491fc5779e7..b57fbaba8a23ed35d6a2ee311598a300055bb82a 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,16 @@ Features -* Automated g!dump'ing of config file (backups?) -* g!sum acid(1) -* Support for acid(1) in g!man +* g!sum acid(1) -- print summary +* Support for acid(1) format in g!man * Search man blocks other than 9front's * Server greeting * 9front/plan9 source searching * various cat-v fetches (harmful, page search [get lucky]) * Auto-propaganda processing for images (Black and White -> (9)-ify) +* g!status -- display status/uptime info +* g!remindme [time] text -- set a reminder for a given time (should work across bot reboots) -- Problems * Move feed caching to another file than the .cfg (seriously this is a fcking mess) - +* Scripts should have a universal config such as an environment variable (more portable/configurable) +* No role/user restrictions (should be a txt file of admin/mod users, maybe) diff --git a/rebuild b/rebuild new file mode 100755 index 0000000000000000000000000000000000000000..4b4a247c381bcdaa46367d5fa75216ac10040892 --- /dev/null +++ b/rebuild @@ -0,0 +1,4 @@ +#!/bin/bash +# Rebuild script for hosting server +go build; killall glenda; ./glenda > /home/seh/glenda.log 2>&1 & + diff --git a/x/mux/lookman/lookman b/x/mux/lookman/lookman index e0ebe4127667602ba11c72d046ad2ecd6c11bf0c..513be4e3821d4f0c02c38036fe905c3444899ae0 100755 --- a/x/mux/lookman/lookman +++ b/x/mux/lookman/lookman @@ -3,7 +3,7 @@ # prints out the names of all manual pages containing all the given keywords rfork e -# Don't forget to change the bottom sed replacement path (variables don't work) +# Change these to match environment sed=/usr/local/plan9port/bin/sed MIRROR=/usr/share/mirror/plan9front index=$MIRROR/sys/lib/man/lookman/index diff --git a/x/mux/man.go b/x/mux/man.go index bb78f791c16a3cde4ecc0e76567a448291cef265..43b83350a68644f535e664a00b1864274ba72cdf 100644 --- a/x/mux/man.go +++ b/x/mux/man.go @@ -22,6 +22,11 @@ var desc []string = []string{ "Section (8) for things related to administering Plan 9."} +// Match a term other than the title of the manual page for a manual page (6a should match the 2a man) +func MatchMan(key string) { + +} + // Fetch a man page func (m *Mux) Man(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) { resp := "\n" @@ -106,7 +111,7 @@ func (m *Mux) Man(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) { } // Fetch a summary of a man page -func (m *Mux) Sum(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) { +func (m *Mux) Summary(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) { } diff --git a/x/mux/man/matchman b/x/mux/man/matchman new file mode 100755 index 0000000000000000000000000000000000000000..b7a248c9ccaa1e271ff9fc4559dc83308b240585 --- /dev/null +++ b/x/mux/man/matchman @@ -0,0 +1,34 @@ +#!/bin/rc +# Usage: matchman key +# Matches all manual pages with the given name as the key + +# Change these to match environment +p9p=/usr/local/plan9port/bin +awk=$p9p/awk +sed=$p9p/sed +grep=$p9p/grep +MIRROR=/usr/share/mirror/plan9front +LIB=$MIRROR/sys/man + +matches = () + +sections = `{seq 8} +for(section in $sections) { + pages = `{ls $LIB/$section/*} + for(page in $pages) { + names = `{$awk 'f{print;f=0} /NAME/{f=1}' $page | awk '{split($0,a, "\\"); print a[1]}' | awk '{split($0,a, "-"); print a[1]}'} + names = `{echo $names | $sed 's/,//g'} + names = `{echo $names | awk '{split($0,a, ", "); for (i in a) print a[i]}'} + + # We now have a list of names at the top of the man page (if the format is correct) + + for(name in $names) { + if(echo $name | $grep -q $1) { + matches = ($matches `{echo $page}) + } + } + } +} + +echo $matches +