Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.

Commit 5a05ec1

Browse files
committed
Add mod command to get a list of channel mods
Signed-off-by: Adam Jimerson <[email protected]>
1 parent 4f521ae commit 5a05ec1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ link to devlunch | Returns the link to the dev lunch live stream
9999
is `username` alive | Returns status of user
100100
\[groups\|meetups\] list | Lists all groups that are known to Ash
101101
\[group\|meetup\] details | Returns details about a group
102+
mods | Returns a list of channel mods currently online
102103

103104
## Contributing
104105

main.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"fmt"
99
"os"
10+
"strings"
1011

1112
"github.com/danryan/hal"
1213
_ "github.com/danryan/hal/adapter/irc"
@@ -16,7 +17,7 @@ import (
1617
)
1718

1819
// VERSION contians the current verison number and revison if need be
19-
const VERSION = "2015-06-09-1"
20+
var VERSION string
2021

2122
// handler is an interface for objects to implement in order to respond to messages.
2223
type handler interface {
@@ -68,6 +69,19 @@ var helpHandler = hear(`help`, "help", "Displays this message", func(res *hal.Re
6869
return nil
6970
})
7071

72+
var modHandler = hear(`mods`, "mods", "Returns a list of channel moderators", func(res *hal.Response) error {
73+
admin := res.Robot.Auth.Admins()
74+
hal.Logger.Debugf("admins: %#v", admin)
75+
76+
var ops []string
77+
for _, a := range admin {
78+
ops = append(ops, a.Name)
79+
}
80+
msg := strings.Join(ops, ", ")
81+
err := res.Reply("Current mods are: " + msg)
82+
return err
83+
})
84+
7185
func hear(pattern string, command string, message string, fn func(res *hal.Response) error) handler {
7286
addHelpMessage(command, message)
7387
return hal.Hear("^(?i)Ash "+pattern, fn)
@@ -127,6 +141,7 @@ func run() int {
127141
karmaHandler,
128142
karmaStatsHandler,
129143
karmaRankingHandler,
144+
modHandler,
130145
)
131146

132147
if err := robot.Run(); err != nil {

0 commit comments

Comments
 (0)