Skip to content

Commit 79433a8

Browse files
committed
FullName fix
1 parent 8b051f2 commit 79433a8

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
git-tag-version=false

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Telegram Bot API ActivityStreams 2.0
1+
# Telegram Bot Messages to ActivityStreams 2.0
22

33
## ActivityStreams 2.0
44

index.cjs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// file object params used, but not required - see https://github.com/qertis/telegram-bot-express
22
const fromUnixTime = require('date-fns/fromUnixTime');
33

4+
const getFullName = (x) => {
5+
return (x.first_name + ' ' + (x.last_name ?? '')).trimEnd()
6+
}
7+
48
const person = (x) => ({
59
type: 'Person',
6-
name: (x.first_name + ' ' + (x.last_name ?? '')).trimEnd(),
10+
name: getFullName(x),
711
id: String(x.id),
812
});
913

@@ -26,7 +30,7 @@ const group = (x) => ({
2630

2731
const profile = (x) => ({
2832
type: 'Profile',
29-
name: x.contact.first_name + ' ' + x.contact.last_name,
33+
name: getFullName(x.contact),
3034
id: String(x.contact.user_id),
3135
to: x.contact.phone_number ? `tel:+${x.contact.phone_number}` : null,
3236
});
@@ -182,9 +186,10 @@ function time(date) {
182186

183187
module.exports = (message) => {
184188
const now = Math.round(new Date().getTime() / 1000)
189+
const context = 'https://www.w3.org/ns/activitystreams'
185190
if (message.channel_post) {
186191
return {
187-
'@context': 'https://www.w3.org/ns/activitystreams',
192+
'@context': context,
188193
type: 'Activity',
189194
instrument: instrument(message),
190195
object: objects(message.channel_post),
@@ -195,7 +200,7 @@ module.exports = (message) => {
195200
}
196201
} else if (message.sender_chat) {
197202
return {
198-
'@context': 'https://www.w3.org/ns/activitystreams',
203+
'@context': context,
199204
type: 'Activity',
200205
instrument: instrument(message),
201206
object: objects(message),
@@ -207,7 +212,7 @@ module.exports = (message) => {
207212
}
208213

209214
return {
210-
'@context': 'https://www.w3.org/ns/activitystreams',
215+
'@context': context,
211216
type: 'Activity',
212217
summary: message.type,
213218
instrument: instrument(message),

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "telegram-bot-activitystreams",
3-
"version": "1.0.1",
4-
"description": "ActivityStreams 2.0 Telegram Bot API",
3+
"version": "1.0.2",
4+
"description": "Telegram Bot Messages ActivityStreams 2.0",
55
"main": "index.cjs",
66
"scripts": {
77
"test": "node test/index.test.cjs"
@@ -13,8 +13,8 @@
1313
"keywords": [
1414
"ActivityStreams 2.0",
1515
"telegram bot api activitystreams",
16-
"telegram bot message activity streams",
17-
"telegram bot api express activitystreams"
16+
"telegram message activity streams",
17+
"telegram bot api express activitystreams 2.0"
1818
],
1919
"author": "Denis Baskovsky (https://baskovsky.ru)",
2020
"license": "MIT",

0 commit comments

Comments
 (0)