Skip to content
This repository has been archived by the owner on Oct 14, 2018. It is now read-only.

Commit

Permalink
data is the new res folder
Browse files Browse the repository at this point in the history
  • Loading branch information
yagop committed Jan 6, 2015
1 parent 859fb48 commit 6c9efc9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
res/
data/
bot/config.lua
2 changes: 1 addition & 1 deletion bot/bot.lua
Expand Up @@ -5,7 +5,7 @@ json = (loadfile "./libs/JSON.lua")()
serpent = (loadfile "./libs/serpent.lua")()
require("./bot/utils")

VERSION = '0.8.1'
VERSION = '0.8.2'

function on_msg_receive (msg)
vardump(msg)
Expand Down
File renamed without changes.
26 changes: 16 additions & 10 deletions plugins/get.lua
@@ -1,15 +1,21 @@
local f = io.open('./res/values.json', "r+")
if f == nil then
f = io.open('./res/values.json', "w+")
f:write("{}") -- Write empty table
f:close()
_values = {}
else
local c = f:read "*a"
f:close()
_values = json:decode(c)
local _file_values = './data/values.lua'

function read_file_values( )
local f = io.open(_file_values, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
print ('Created value file '.._file_values)
serialize_to_file({}, _file_values)
else
print ('Stats loaded: '.._file_values)
f:close()
end
return loadfile (_file_values)()
end

_values = read_file_values()

function fetch_value(chat, value_name)
if (_values[chat] == nil) then
return nil
Expand Down
8 changes: 4 additions & 4 deletions plugins/set.lua
@@ -1,3 +1,5 @@
local _file_values = './data/values.lua'

function save_value(chat, text )
var_name, var_value = string.match(text, "!set (%a+) (.+)")
if (var_name == nil or var_value == nil) then
Expand All @@ -8,10 +10,8 @@ function save_value(chat, text )
end
_values[chat][var_name] = var_value

local json_text = json:encode_pretty(_values)
file = io.open ("./res/values.json", "w+")
file:write(json_text)
file:close()
-- Save values to file
serialize_to_file(_values, _file_values)

return "Saved "..var_name.." = "..var_value
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/stats.lua
Expand Up @@ -4,7 +4,7 @@
do

local socket = require('socket')
local _file_stats = './res/stats.lua'
local _file_stats = './data/stats.lua'
local _stats

function update_user_stats(msg)
Expand Down

5 comments on commit 6c9efc9

@Akronix
Copy link

@Akronix Akronix commented on 6c9efc9 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance to stop this spam?

@rockneurotiko
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @yagop can block the user

@yagop
Copy link
Owner Author

@yagop yagop commented on 6c9efc9 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I can't.

@voiser
Copy link
Collaborator

@voiser voiser commented on 6c9efc9 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reported the user as a spammer, hope he is banned from Github

@yagop
Copy link
Owner Author

@yagop yagop commented on 6c9efc9 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to think he was testing GitHub Markdown rather than being a spammer.
I see on with his feed he were doing a git tutorial and he has removed some comments but others remains untouched. Let's hope he wont disturb us.

No one mess with @voiser no one!
http://i.giphy.com/9qMIBqOJrtvfW.gif

Please sign in to comment.