I looked through hubot's /src folder on github and didn't see a 'username' function defined under the user class. Where can I see the source for this on mafiabot? I'm trying to see all of the attributes listed, it'd be nice if I could run it to debug and see what the data is..
result = getDay(threadId)
Where is the source for these commands like getDay/getGame etc? Edit: NVM I think I found it in start_game.coffee
Would it be possible to create a duplicate instance of the mafiabot like 'testbot' or 'stovebot' which has permissions set to allow me to push directly into the directory and test code so I don't mess w/ the underlying mafiabot until bugs have been ironed out?
Looks like you already wrote a sub command into play_game.coffee.
# HOST Subs a player in the current Day
robot.hear /@mafiabot sub (.*)/i, (res) ->
host = res.envelope.user.username
targets = res.match[1] . replace '@', ''
threadId = res.message.room
result = getDay(threadId)
result.then (data) ->
if data.Count > 0
for item in data.Items
# Add User to Signup
if host is item.host
subPlayer(threadId, item.alive_players, targets)
Reading through it, looks like the function is incomplete.
Here's my suggested edit with #### on the changes.
Call:
# HOST Subs a player in the current Day
####robot.hear /@mafiabot sub (.*) for (.*)/i, (res) ->
host = res.envelope.user.username
####sub_out = res.match[1] . replace '@', ''
####sub_in = res.match[2] . replace '@', ''
threadId = res.message.room
result = getDay(threadId)
result.then (data) ->
if data.Count > 0
for item in data.Items
if host is item.host
####subPlayer(threadId, sub_out, sub_in)
Function:
subPlayer = (threadId, sub_out, sub_in) ->
#verify player being subbed is alive and in the game
if sub_out in game[0].alive_players
#grab index containing the player to be subbed out
index = game[0].alive_players.indexOf(sub_out)
#replace the player
game[0].alive_players[index] = sub_in
##########################################################
Does item.alive_players also need to be updated as well? So item.alive_players = game[0].alive_players ? IDK if this is updating the value or the reference.
Is there any way to make a duplicate instance like @testbot to push the test code into before finalizing to @mafiabot so it doesn't brick any running games? I have code written out, but I'm not sure about pushing to prod without testing first.
Would pushing a code change have any impact on ongoing games?
last time i was "testing the code" i was straightup making commits to a repo and then some jenkins shit was running the bot so id just test teh commands somewhere
what kinda adapter would you want to mess around with? i linked this article cuz the beginning references the alternatives, i was gonna link https://github.com/hubotio/hubot-mock-adapter for our use
realtalk if you would host it i might ask that we just have the bot just handle post and get from some small node+w/e service that ill write so we can begin separating logic from the thing handling the presentation. then we'd get to also drop coffeescript and easily integrate tests etc
also in addition to the new service you should/would have to also run a duplicate of mafiabot for prod during the transition