Download src/wp/controllers/groupsController.js from pnacorp/xsender: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/pnacorp/xsender/resolve/main/src/wp/controllers/groupsController.js
- Command line
-
hf download hf://pnacorp/xsender/src/wp/controllers/groupsController.js
-
curl -L -o groupsController.js https://huggingface.co/pnacorp/xsender/resolve/main/src/wp/controllers/groupsController.js
1.31 kB
| import { getSession, getChatList, isExists, sendMessage, formatGroup } from './../../whatsapp.js' | |
| import response from './../../response.js' | |
| const getList = (req, res) => { | |
| return response(res, 200, true, '', getChatList(res.locals.sessionId, true)) | |
| } | |
| const getGroupMetaData = async (req, res) => { | |
| const session = getSession(res.locals.sessionId) | |
| const { jid } = req.params | |
| try { | |
| const data = await session.groupMetadata(jid) | |
| if (!data.id) { | |
| return response(res, 400, false, 'The group is not exists.') | |
| } | |
| response(res, 200, true, '', data) | |
| } catch { | |
| response(res, 500, false, 'Failed to get group metadata.') | |
| } | |
| } | |
| const send = async (req, res) => { | |
| const session = getSession(res.locals.sessionId) | |
| const receiver = formatGroup(req.body.receiver) | |
| const { message } = req.body | |
| try { | |
| const exists = await isExists(session, receiver, true) | |
| if (!exists) { | |
| return response(res, 400, false, 'The group is not exists.') | |
| } | |
| await sendMessage(session, receiver, message) | |
| response(res, 200, true, 'The message has been successfully sent.') | |
| } catch { | |
| response(res, 500, false, 'Failed to send the message.') | |
| } | |
| } | |
| export { getList, getGroupMetaData, send } | |