Guest User

Untitled

a guest
Feb 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. --| Chat Logger for HHFH by hjpotter92 and Brick
  2.  
  3. dofile("scripts/libsimplepickle.lua")
  4. if not count then
  5. count ={}
  6. end
  7.  
  8. local p = io.open( "scripts/ChatLogs/count.txt", "r" )
  9.  
  10. if p then
  11. dofile("scripts/ChatLogs/count.txt")
  12. p:close()
  13. end
  14.  
  15. dcpp:setListener( "chat", "monologue",
  16. function( hub,user,text)
  17. local name = "scripts/ChatLogs/"..os.date( "%Y" ).."/"..os.date( "%m" ).."/"..os.date("%d").."_"..os.date("%m").."_"..os.date("%Y")..".txt"
  18. local f = io.open (name,"a")
  19. local a= "["..os.date("%I")..":"..os.date("%M").." "..os.date("%p").."] ".."<"..user:getNick().."> "..text
  20. f:write(a.."\n")
  21. f:flush()
  22. f:close()
  23. if not count[user:getNick()] then
  24. count[user:getNick()] =0
  25. end
  26. count[user:getNick()] = count[user:getNick()] + 1
  27. local tempVar = count[user:getNick()]
  28. local cent = tempVar - math.floor( tempVar/100 ) * 100
  29. if cent == 0 then
  30. hub:sendChat(".say hjpotter92 The user "..user:getNick().." just punched 100th line on mainchat. The current count being: "..count[user:getNick()] )
  31. end
  32. pickle.store("scripts/ChatLogs/count.txt",{count=count})
  33. end
  34. )
  35.  
  36. local h = io.open( "scripts/ChatLogs/chatLogHelp.txt", "r" )
  37. local totcounts = h:read( "*a" )
  38.  
  39.  
  40. dcpp:setListener( "pm", "response",
  41. function( hub, user, text )
  42. local p = io.open( "scripts/ChatLogs/count.txt", "r" )
  43. local fileData = p:read( "*a" )
  44. p:close()
  45. local s = string.lower( text )
  46. if string.find( s, "score" ) then
  47. user:sendPrivMsgFmt( "\r\t"..user:getNick()..", your score is "..count[user:getNick()]..".\n\tBot designed by Brick and hjpotter92.", 1 )
  48. elseif string.find( s, "help" ) then
  49. user:sendPrivMsgFmt( totcounts, 1)
  50. elseif string.find( s, "count" ) then
  51. user:sendPrivMsgFmt( fileData, 1)
  52. end
  53. end
  54. )
  55. DC():PrintDebug( " ** Loaded Chat Log.lua **" )
Add Comment
Please, Sign In to add comment