Compare commits
3 Commits
f29bc83d56
...
connectme-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ee5ca5528 | ||
| e1e335098e | |||
| 619975d1e0 |
@@ -89,6 +89,7 @@ app.use("/freetracker", require("./routers/freetracker"))
|
|||||||
app.use("/dhs-testing", require("./routers/dhs-testing"))
|
app.use("/dhs-testing", require("./routers/dhs-testing"))
|
||||||
app.use("/gamehub", require("./routers/gamehub"))
|
app.use("/gamehub", require("./routers/gamehub"))
|
||||||
app.use("/esc", require("./routers/esc"))
|
app.use("/esc", require("./routers/esc"))
|
||||||
|
app.use('/connectme', require('./routers/connectme'))
|
||||||
|
|
||||||
app.use(require("./error"))
|
app.use(require("./error"))
|
||||||
|
|
||||||
|
|||||||
8
server/routers/connectme/index.js
Normal file
8
server/routers/connectme/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const { Router } = require('express')
|
||||||
|
const router = Router()
|
||||||
|
|
||||||
|
router.get('/cities', (request, response) => {
|
||||||
|
response.send(require('./json/cities.json'))
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
85
server/routers/connectme/json/cities.json
Normal file
85
server/routers/connectme/json/cities.json
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"title": "Моска"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"title": "Санкт-петербург"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"title": "Новосибирска"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"title": "Екатеринбург"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"title": "Казань"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"title": "Нижний новгород"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"title": "Челябинск"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"title": "Самара"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"title": "Омск"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"title": "Ростов-на-дону"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"title": "Уфа"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12,
|
||||||
|
"title": "Красноярск"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 13,
|
||||||
|
"title": "Пермь"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 14,
|
||||||
|
"title": "Воронеж"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 15,
|
||||||
|
"title": "Волгоград"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 16,
|
||||||
|
"title": "Краснодар"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 17,
|
||||||
|
"title": "Тюмень"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 18,
|
||||||
|
"title": "Ижевск"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 19,
|
||||||
|
"title": "Барнаул"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 20,
|
||||||
|
"title": "Владивосток"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"count": 20
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ const interestsRouter = require('./interests');
|
|||||||
const usersRouter = require('./users');
|
const usersRouter = require('./users');
|
||||||
const eventsRouter = require('./events');
|
const eventsRouter = require('./events');
|
||||||
const gigachatRouter = require('./gigachat');
|
const gigachatRouter = require('./gigachat');
|
||||||
|
const telegramRouter = require('./telegram');
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
||||||
const delay =
|
const delay =
|
||||||
@@ -16,3 +17,4 @@ router.use('/interests', interestsRouter);
|
|||||||
router.use('/users', usersRouter);
|
router.use('/users', usersRouter);
|
||||||
router.use('/events', eventsRouter);
|
router.use('/events', eventsRouter);
|
||||||
router.use('/gigachat', gigachatRouter);
|
router.use('/gigachat', gigachatRouter);
|
||||||
|
router.use('/telegram', telegramRouter);
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
const axios = require('axios');
|
||||||
|
|
||||||
|
process.env.TELEGRAM_TOKEN = '7866617284:AAHDOfPQJdKmufOdRgFza6XA8ZWRHPeA_Yc';
|
||||||
|
|
||||||
|
class controller {
|
||||||
|
async sendMessage(req, res) {
|
||||||
|
try {
|
||||||
|
const { chat_id, text } = req.body;
|
||||||
|
|
||||||
|
const response = await axios.get(`https://api.telegram.org/bot${process.env.TELEGRAM_TOKEN}/sendMessage`, {
|
||||||
|
params: {
|
||||||
|
chat_id: chat_id,
|
||||||
|
text: text,
|
||||||
|
parse_mode: 'html'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
res.json(response.data);
|
||||||
|
} catch (e) {
|
||||||
|
res.status(400).json({ message: e.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new controller();
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const router = require('express').Router();
|
||||||
|
const controller = require('./controller');
|
||||||
|
|
||||||
|
router.post('/', controller.sendMessage);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user