Skip to content

Commit

Permalink
Renamed methods in users.go
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Oct 4, 2015
1 parent 58f597f commit 947c7e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func cmdAuth(ctx Ctx) (replayMsg string) {
}
secretCodeMsg := fmt.Sprintf("Request %saccess for %s. Code: %s\n", rootRoleStr, ctx.users.String(ctx.userID), authCode)
fmt.Print(secretCodeMsg)
ctx.users.broadcastForRoots(ctx.bot, secretCodeMsg)
ctx.users.BroadcastForRoots(ctx.bot, secretCodeMsg)

} else {
if ctx.users.IsValidCode(ctx.userID, ctx.messageArgs, forRoot) {
Expand Down Expand Up @@ -136,10 +136,10 @@ func cmdShell2telegramBan(ctx Ctx) (replayMsg string) {
userID, err := strconv.Atoi(userName)
if err != nil {
userName = regexp.MustCompile("@").ReplaceAllLiteralString(userName, "")
userID = ctx.users.getUserIDByName(userName)
userID = ctx.users.GetUserIDByName(userName)
}

if userID > 0 && ctx.users.banUser(userID) {
if userID > 0 && ctx.users.BanUser(userID) {
replayMsg = fmt.Sprintf("User %s banned", ctx.users.String(userID))
} else {
replayMsg = "User not found"
Expand Down
2 changes: 1 addition & 1 deletion shell2telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ LOOP:
}

case <-vacuumTicker:
users.clearOldUsers()
users.ClearOldUsers()
}
}
}
8 changes: 4 additions & 4 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (users Users) IsRoot(userID int) bool {
}

// broadcastForRoots - send message to all root users
func (users Users) broadcastForRoots(bot *tgbotapi.BotAPI, message string) {
func (users Users) BroadcastForRoots(bot *tgbotapi.BotAPI, message string) {
for _, user := range users.list {
if user.IsRoot && user.PrivateChatID > 0 {
sendMessageWithLogging(bot, user.PrivateChatID, message)
Expand Down Expand Up @@ -173,7 +173,7 @@ func (users Users) StringVerbose(userID int) string {
}

// clearOldUsers - clear old users without login
func (users Users) clearOldUsers() {
func (users Users) ClearOldUsers() {
for id, user := range users.list {
if !user.IsAuthorized && !user.IsRoot && user.Counter == 0 &&
time.Now().Sub(user.LastAccessTime).Seconds() > SECONDS_FOR_OLD_USERS_BEFORE_VACUUM {
Expand All @@ -184,7 +184,7 @@ func (users Users) clearOldUsers() {
}

// getUserIDByName - find user by login
func (users Users) getUserIDByName(userName string) int {
func (users Users) GetUserIDByName(userName string) int {
userID := 0
for id, user := range users.list {
if userName == user.UserName {
Expand All @@ -197,7 +197,7 @@ func (users Users) getUserIDByName(userName string) int {
}

// banUser - ban user by ID
func (users Users) banUser(userID int) bool {
func (users Users) BanUser(userID int) bool {
if _, ok := users.list[userID]; ok {
users.list[userID].IsAuthorized = false
users.list[userID].IsRoot = false
Expand Down

0 comments on commit 947c7e5

Please sign in to comment.