Sure, np!
Language: Lua
Operating Files: Discord bot, FFXI add-on
Additional Files: incoming FFXI messages.text, incoming Discord messages .txt
Uses:
-Windower functions (for incoming chat, adding messages into FFXI)
-io text file manipulation in Lua
-table creation/manipulation in Lua
-Discord API
-Discord markdown
Initialization:
Player runs add-on on their character through Windower, bot is activated through Luvit using command prompt.
Writing:
The add-on runs in Windower and listens for incoming messages in the linkshell, shout, or tell channels. Upon receiving that data, it concatenates channel source, sender, and message into a string and dumps it into a new line in the FFXI_messages.txt.
The Discord bot is triggered similarly by incoming messages from particular channels or with leading characters (like "/l"). Eligible messages are packed into a string and dumped into Discord_messages.txt.
Reading:
At regular intervals, the add-on opens Discord_messages.txt and copies every line into a table, it then clears the file in preparation for more data. The table's data is then read, processed and handled in FFXI.
-Any message from the linkshell_chat_link channel is prefaced with "/l", limiting general access to linkshell communication.
-Messages from the private tell_chat_link channel are simply processed as input, allowing users in that channel the same access as if typing input directly into the game. Things like /tell, /target, /follow, /yell, etc act as if typed directly into FFXI.
Similarly, FFXI_messages.txt is opened by the Discord bot regularly and the data is stored line-by-line to a table. The file is cleared and ready for more data. The table's lines are then processed and routed to channels for: shouts, linkshell, and tells. The lines are formatted as such: channel/sender with stylized markdown/begin blocking code/message/end blocking code. Channel is removed and used for routing, the rest is passed as-is and used for displaying the messages in Discord.
Watch Words:
Discord users can add words that they'd like to be alerted to upon mention. This could include their name, nickname, content they're interested in, etc. Issuing "!watch <word or phrase to watch for>" will add the Discord user_id and watch word to a table. This table gets compared to each message and pings any users who's watch words are found. The user is pinged with the watch word, letting them know exactly what was found and why they were pinged.
"!unwatch <word or phrase>" can be used to remove a word from the list.
!tells/!notells:
Activates boolean to decide wether or not player issued direct commands (not just "/l"-prefaced ones) can be handed into FFXI.
Currently, everything except the !tell boolean and watch words are simply pass-through from bot, file, client or back the other way.