~singpolyma/cheogram

dbfd94f41c7b038408fb653e4b70cee613b889ee — Stephen Paul Weber a month ago 78d11de
Ask for action when filling out a form with no fields
1 files changed, 12 insertions(+), 1 deletions(-)

M Adhoc.hs
M Adhoc.hs => Adhoc.hs +12 -1
@@ 589,7 589,18 @@ adhocBotRunCommand db componentJid routeFrom sendMessage sendIQ getMessage from 
					let cancelText = sendText . ((mapNode cmd ++ s" ") ++)
					forM_ intro sendText
					returnForm <- adhocBotAnswerForm sendText (withCancel sessionLifespan cancelText cancel getMessage) form
					continueExecution resultIQ [NodeElement returnForm]
					if null $ XML.elementChildren returnForm then do
						let actions = mapMaybe (actionFromXMPP . XML.nameLocalName . elementName) $ elementChildren =<< isNamed (s"{http://jabber.org/protocol/commands}actions") =<< elementChildren payload
						let sessionid = maybe [] (\sessid -> [(s"sessionid", [ContentText sessid])]) $ attributeText (s"sessionid") payload
						action <- waitForAction actions sendText (atomicUIO getMessage)
						let cmdIQ' = (emptyIQ IQSet) {
							iqFrom = Just routeFrom,
							iqTo = iqFrom resultIQ,
							iqPayload = Just $ Element (s"{http://jabber.org/protocol/commands}command") ([(s"node", [ContentText $ fromMaybe mempty $ attributeText (s"node") payload]), (s"action", [actionContent action])] ++ sessionid) [NodeElement returnForm]
						}
						sendAndRespondTo Nothing cmdIQ'
					else
						continueExecution resultIQ [NodeElement returnForm]
				| IQResult == iqType resultIQ,
				  Just payload <- iqPayload resultIQ,
				  notes@(_:_) <- isNamed (s"{http://jabber.org/protocol/commands}note") =<< elementChildren payload -> do