-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig.sample.yml
157 lines (133 loc) · 5.79 KB
/
config.sample.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Telegram client configuration
telegram:
api_id: <your API ID from https://my.telegram.org>
api_hash: <your API hash from https://my.telegram.org>
session_file: /path/to/your/client.session
# Chat types which should be monitored
chat_types:
- contact # Users added as contact
- user # Users not added as contact
- group # Groups (including mega groups)
- channel # Channels (excluding mega groups)
# List of chats to monitor additionally to those specified using "chat_types"
# The command "list-chats" can be used to get specific IDs
additional_chats:
- <id 1>
- <id 2>
- ...
# Configure whether messages should be translated into the specified language
# Use the two-letter ISO 639-1 language code (examples: "de", "en", "es", "it")
# Omit or keep empty to disable translations
translate_to_lang: "en"
media:
# Path where to put media files
download_path: /path/where/to/put/media-files
# Pattern of the saved filename
#
# Available placeholders:
# {date.year}: Year from the message date
# {date.month}: Month from the message date
# {date.day}: Day from the message date
# {date.hour}: Hour from the message date
# {date.minute}: Minute from the message date
# {date.second}: Second from the message date
# {file.name}: Original name of the file (without file extension)
# {file.ext}: Extension of the file (without leading dot, i.e. "jpg")
# {message.id}: ID of the message
#
# You might also use directory separators to create subdirectories
file_pattern: "{date[year]}-{date[month]}-{date[day]}_{date[hour]}-{date[minute]}-{date[second]}_{message[id]}_{file[name]}.{file[ext]}"
# Limit the maximum size for media downloads
# Omit or keep empty to disable limit
max_size: 10M
# Configure rules to define whether to download media for specific media types, mime types, chat types and/or contacts
# If there is at least one rule, downloading will be disabled by default until a matching configuration is found
# The first matching rule will be used
# You might also specify "download_path", "max_size" and "file_pattern" in a rule to change them for a specific rule.
# media_type, mime_type and chat_type might be also configured as a regular expression by using media_type_re, mime_type_re and chat_type_re instead
rules:
# This rule will enable downloads of photos up to 10 MB for specific contacts
- media_type: photo
chat_type: contact
chats:
- <id 1>
- <id 2>
- ...
max_size: 10M
# This rule will allow any media download regardless of the media type but limit it to 50 MB per media download and put the files in "/downloads/channels"
- chat_type: channel
max_size: 50M
download_path: /downloads/channels
# This rule will allow to download any JPEG image
- mime_type: image/jpeg
# This rule will allow to download any image ("mime_type_re" will match using a regular expression)
- mime_type_re: image
# This rule will accept any media download with a maximum size of 5 MB
- max_size: 5M
outputs:
# Send messages to Elasticsearch
- type: elasticsearch
host: http://your-elastic-host:9200
# Username and password used to authenticate at Elasticsearch (optional)
username: <Elasticsearch user>
password: <Elasticsearch password>
# Format of the index to use (will be passed to strftime)
index_format: "telegram-%Y.%m.%d"
# Specify your own output map to be used for each message
# The key defines the target property
# The value defines the Python code which should be executed to get the value for the property
# The keys "id" and "date" are not used as they are automatically mapped to the "id" and "timestamp" fields respectively
output_map:
sender: "sender"
chat: "get_display_name(await message.get_chat())"
message: "message.text"
media: "media.filename if media else None"
# Append messages to a list in Redis
- type: redis
host: some-host
port: 6379
db: 0
# Optionally specify username and password
username: <Redis user>
password: <Redis password>
# Redis key into which the list should be stored
# Each message is encoded as JSON and appended to that list using the `RPUSH` Redis command
key: some_name
# Specify your own output map to be used for each message
# The key defines the target property
# The value defines the Python code which should be executed to get the value for the property
output_map:
id: "message.id"
date: "message.date"
sender: "sender"
chat: "get_display_name(await message.get_chat())"
message: "message.text"
media: "media.filename if media else None"
# Send messages to any host using TCP (e.g. for using TCP input of Logstash)
- type: tcp
host: some-host
port: 1234
# Specify your own output map to be used for each message
# The key defines the target property
# The value defines the Python code which should be executed to get the value for the property
output_map:
id: "message.id"
date: "message.date"
sender: "sender"
chat: "get_display_name(await message.get_chat())"
message: "message.text"
media: "media.filename if media else None"
# Write messages to a file (in JSON format - one JSON object per line)
- type: file
path: /path/to/your/file.log
# Specify your own output map to be used for each message
# The key defines the target property
# The value defines the Python code which should be executed to get the value for the property
output_map:
id: "message.id"
date: "message.date"
sender: "sender"
chat: "get_display_name(await message.get_chat())"
message: "message.text"
translated_message: "translated_text"
media: "media.filename if media else None"