Skip to content

Instantly share code, notes, and snippets.

@Onurtag
Last active June 4, 2019 10:45
Show Gist options
  • Save Onurtag/ad954fe888c57c782074f7f992dd9be2 to your computer and use it in GitHub Desktop.
Save Onurtag/ad954fe888c57c782074f7f992dd9be2 to your computer and use it in GitHub Desktop.
TakeNotes.lua - VERY basic Hexchat IRC client script for taking notes.

Get it using the "raw" button or unicode color values might not be there.

hexchat.register("TakeNotes.lua", "1.0", "Take Notes and view them.")
local help_read = "Usage: /rnt ═ READ FILE"
local help_append = "Usage: /wnt ═ NEW TEXT TO APPEND TO FILE"
local help_replace = "Usage: /replacent ═ NEW TEXT TO REPLACE EVERYTHING"
local help_help = "Enter /helpnt"
local function read_note(word, eol)
local file = io.open(hexchat.get_info"configdir" .. "/Notes.txt", "r")
if file then
print()
print("12╔═══════════════════════════════════════════════════════════════════════════════════════════════╗")
print("12║ ╔═══════════════════════════════════════════════════════════════════════════════════════════╗ ║")
print("12║ ║ ███████╗ █████╗ ██╗ ██╗███████╗██████╗ ███╗ ██╗ ██████╗ ████████╗███████╗███████╗ ║ ║")
print("12║ ║ ██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗ ████╗ ██║██╔═══██╗╚══██╔══╝██╔════╝██╔════╝ ║ ║")
print("12║ ║ ███████╗███████║██║ ██║█████╗ ██║ ██║ ██╔██╗ ██║██║ ██║ ██║ █████╗ ███████╗ ║ ║")
print("12║ ║ ╚════██║██╔══██║╚██╗ ██╔╝██╔══╝ ██║ ██║ ██║╚██╗██║██║ ██║ ██║ ██╔══╝ ╚════██║ ║ ║")
print("12║ ║ ███████║██║ ██║ ╚████╔╝ ███████╗██████╔╝ ██║ ╚████║╚██████╔╝ ██║ ███████╗███████║ ║ ║")
print("12║ ║ ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚══════╝╚══════╝ ║ ║")
print("12║ ╚═══════════════════════════════════════════════════════════════════════════════════════════╝ ║")
print("12╠═══════════════════════════════════════════════════════════════════════════════════════════════╣")
print("12║ ║")
print()
for line in file:lines() do
print(" 8" .. line)
end
print()
print()
print("12║ ║")
print("12║ ║")
print("12╠═══════════════════════════════════════════════════════════════════════════════════════════════╣")
print("12║ Commands: /rnt, /wnt, /replacent ║")
print("12╚═══════════════════════════════════════════════════════════════════════════════════════════════╝")
print()
file:close()
end
end
local function append_note(word, eol)
local file = io.open(hexchat.get_info"configdir" .. "/Notes.txt", "a")
if file then
file:write("\n")
table.remove(word,1)
file:write(table.concat(word," "))
file:close()
end
end
local function replace_note(word, eol)
local file = io.open(hexchat.get_info"configdir" .. "/Notes.txt", "w")
if file then
table.remove(word,1)
file:write(table.concat(word," "))
file:close()
end
end
local function help_note(word, eol)
print()
print(help_read)
print(help_append)
print(help_replace)
print()
end
hexchat.hook_command("HELPNT", help_note, help_help)
hexchat.hook_command("RNT", read_note, help_read)
hexchat.hook_command("WNT", append_note, help_append)
hexchat.hook_command("REPLACENT", replace_note, help_replace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment