Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions scripts/most-spoken-words.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Description:
# Listen all the words spoken by a user.
# Listen all the words spoken by a user.
# Builds a dictionary of words along with the number of times it was spoken.
# Display the words spoken by a particular user in desc order.
# Show message stats
#
# Dependencies:
# natural - https://www.npmjs.com/package/natural
Expand All @@ -11,6 +12,7 @@
#
# Commands:
# bot show me words spoken by me
# bot stats
#
# Author:
# csoni111
Expand Down Expand Up @@ -41,6 +43,7 @@ module.exports = (robot) ->
if words.length > 0
name = msg.message.user.name
user = robot.brain.userForName name
user.msgcount = user.msgcount+1
if typeof user is 'object'
user.words = user.words or {}
if Object.keys(user.words).length > 25
Expand Down Expand Up @@ -72,8 +75,18 @@ module.exports = (robot) ->
msg.send msg.random responses


robot.respond /.*stats/i, (msg) ->
name = msg.message.user.name
user = robot.brain.userForName name
response = "```*Name : Message Count*\n"
for own key, user of robot.brain.data.users
if user.msgcount>0
response += "#{user.name} : " + (user.msgcount or 0) + "\n"
msg.send response+"```"+"\nCan't find your name?\n" + msg.random responses


responses = [
'Looks like you are more of a silent man'
'There ain\'t anything for you!'
'Be more active next time!'
]
]