Started Working On A Discord/XI Link!

Eorzea Time
 
 
 
Langues: JP EN FR DE
users online
Forum » Windower » General » Started working on a Discord/XI link!
Started working on a Discord/XI link!
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-20 02:51:25
Link | Citer | R
 


Currently it dumps shouts into the shout channel.

To implement:
Routing for linkshell chat into the LS chat channel.
Allowing responses from Discord to enter the game.
Potentially allowing commands entered in Discord to control actions in-game (ex: there's an upload file function that the Discord bot can use; if I enter a Discord command, my character in-game can take a picture and upload it to Discord for me to see!)

I'm not sure how portable it will end up being, right now it's tied to our linkshell's channel ID's.

It's a fun little project so far! Will update as it comes along!
[+]
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-21 15:23:37
Link | Citer | R
 
Linkshell chat link works!

Currently:
-Shouts go to #asura-shouts channel
-LS messages go to #ls-chat-link channel
-all replies in #ls-chat-link delivered to in-game linkshell
-Discord commands prefaced with "/l" delivered to in-game linkshell

Back end:
-fixed zoning bug that caused Discord bot to crash
-fixed overflow routing improperly
-fixed grouped messages being treated as block

To-Do:
-MINOR: Recolor Discord chat to give it more FFXI feel?
-MAJOR: Push bot to server and adjust add-on accordingly (to push towards universality of the project, currently 'in-house' only)





*edit: added a couple pictures from mobile
[+]
Offline
Posts: 634
By zaxtiss 2018-05-21 15:26:42
Link | Citer | R
 
cool beans! keep it up!
[+]
 Asura.Kazaki
Offline
Serveur: Asura
Game: FFXI
user: Kazaki
Posts: 121
By Asura.Kazaki 2018-05-21 15:35:49
Link | Citer | R
 
This is awesome!
[+]
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-22 12:44:43
Link | Citer | R
 
Added:
-channel in Discord to receive tells
-tells received and routed properly
-added listener in private tells channel for messages beginning with ”/”, sends them as input commands to FFXI

Description:
In Discord: Made a private channel for tells and command input. Can receive and respond to tells or input any other input commands from here! Tells, shout, emotes, etc all work! Even things like /target, /follow, /trade can be issued from Discord! Additionally, access to this channel can be granted to anyone in the server, letting them see tells and enter commands in game (yikes!)

Additionally, the admin can issue ”!notells" to turn off routing of private tell messages and "!tells" to turn them back on. This is so others can be granted access to the client running Chatlink but privacy is maintained.

 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-22 17:16:46
Link | Citer | R
 
Added "!watch" and "!unwatch" commands in Discord.
-"!watch <word or phrase>" will have the bot ping you if that word comes up in tell, shout or LS
-"!unwatch <word or phrase>" removes the watch word



Bugs:
There's a multiline shout bug that Kapao is helping me with, I'll get it sorted soon! Currently crashes the whole thing (yikes!)
Offline
Posts: 1584
By Felgarr 2018-05-23 03:00:23
Link | Citer | R
 
Very cool!

Where Is the source of truth? A logged in character, running a plugin that POSTs messages somewhere? Are the messages cache somewhere before being displayed in the channel? Do you mind sharing the architecture? Thanks!
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-23 12:04:56
Link | Citer | R
 
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.
[+]
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-24 15:43:32
Link | Citer | R
 
Recently:
Began converting test bed into a universal bot/add-on package.
-created external file for server settings and bot key.
-modified path files in add-on to generate based on location, previously my personal file path was supplied.

Began work on duplicate message filter with a few goals in mind:
-reduce spam from repetitive shouts.
-allow for multiple bots to report shouts (multiple users running their own bots). This will offer more full coverage; if one person is zoning or not in town, another user's bot can be reporting shouts and linkshell messages.

Bugs Squashed:
-fixed a major bug regarding Lua and % as escape character.
-fixed multiline Discord messages from splitting into different messages in FFXI.

To-Do:
Add more user controls:
-toggle reporting: shouts, linkshell, tells (done)
-adjust spam tolerance
-add a blacklist to block certain messages or senders

I've started messing with GitHub. I'm unfamiliar with it but looking to post both the bot and the add-on files there.

I've still got a lengthy setup guide to write but we're near ready to release!
 Asura.Gamergiving
Offline
Serveur: Asura
Game: FFXI
Posts: 16
By Asura.Gamergiving 2018-05-26 18:15:11
Link | Citer | R
 
Update:
Tackled a major roadblock!

The intent was for multiple users to be able to run their own bots and add-ons. This way, shout and linkshell coverage can be more full, even if one user or another is out of town/shout range. Additionally, each user can control their character, access tells, etc.

Consider:
With multiple setups running, the same shouts and linkshell messages get passed to Discord multiple times. Not ideal.

My initial fix was to build a chat log to compare incoming data with data already displayed and discard duplicates. This works well for shout spammers but the multiple client messages are usually read and processed concurrently before either has a chance to add the message to the skip list. In high lag situations, this worked some of the time.

The next thing I did was try to get the bots to communicate with each other and offset through assignment. I learned how to populate a 'clients in channel' list and then cut it down to just bots. From there, I hoped to handshake and organize priority through private messages. Unfortunately, Discord bots cannot PM each other.

Finally, I settled on the bots adding a command upon entering the server. This causes all of the bots to clear their bot table and respond with the matching handshake. Responders are added to each bot's bot list. These lists are then sorted so that they mirror each other. Each client then offsets a certain amount of time based on their position on the list. If a bot disconnects from Discord, it's removed from the other bots' lists, they re-sort and continue.

Ex:
With 1 client, all data processed by 1 bot every 3 seconds. Another bot logs in, begins handshake. They respond to each other and populate bot lists with each other. The lists sort based on IDs. The bot with the lowest ID processes data, 3 seconds later the other bot processes data. Three seconds later, it starts again. Each bot only acts every 6 seconds.

Eventually, 1 bot disconnects. The other bot removes them from the list, re-sorts and increases to processing every 3 seconds.

Instead of stepping all over each other, they decrease the workload for each other!

This was the last major hurdle before release! Just a few toggles to add and you can hook this up to your Discord!
necroskull Necro Bump Detected! [1990 days between previous and next post]
Offline
Posts: 31
By Pirates 2023-11-06 17:12:12
Link | Citer | R
 
Huge necro here but does anyone have a working app for this?