lita-telegram 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +25 -0
- data/Rakefile +6 -0
- data/lib/lita-telegram.rb +9 -0
- data/lib/lita/adapters/telegram.rb +38 -0
- data/lita-telegram.gemspec +26 -0
- data/locales/en.yml +4 -0
- data/spec/lita/adapters/telegram_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 15f7400a9c1699f5d97520d3f2f12d088553c752
|
4
|
+
data.tar.gz: cc8e2f2c857f35f50d3d3ee0c8287bbabce25e4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d57f2d5de80de9291ad50c78f96c602d53fd5e8e5d6bd6fe8f856c6d8082025e421d017507f418b4c02a9213e4e5149c6143a69fde8d09492b6d1b78fe529b88
|
7
|
+
data.tar.gz: 7f8387c927b026e9c8b1fea8fc5eba696d544b4470e5f085d5862b2bba782dcd65733ff530171c9df03c3764af1dc76b7e0791f721fb42b320492976d29094f2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Rob McFadzean
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# lita-telegram
|
2
|
+
|
3
|
+
Lita adapter for (Telegram Bots)[https://core.telegram.org/bots]. See the link for setup instructions.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-telegram to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-telegram"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
### lita_config.rb
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
config.robot.adapter = :telegram
|
19
|
+
config.adapters.telegram.telegram_token = ENV['TELEGRAM_TOKEN']
|
20
|
+
```
|
21
|
+
|
22
|
+
## TODO
|
23
|
+
|
24
|
+
* Tests
|
25
|
+
* Handle sending/receiving different message types
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Lita
|
2
|
+
module Adapters
|
3
|
+
class Telegram < Adapter
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
config :telegram_token, type: String, required: true
|
7
|
+
|
8
|
+
def initialize(robot)
|
9
|
+
super
|
10
|
+
@client = ::Telegram::Bot::Client.new(config.telegram_token, logger: ::Logger.new($stdout))
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
client.listen do |message|
|
15
|
+
user = Lita::User.find_by_name(message.from.username)
|
16
|
+
user = Lita::User.create(message.from.username) unless user
|
17
|
+
|
18
|
+
chat = Lita::Room.new(message.chat.id)
|
19
|
+
|
20
|
+
source = Lita::Source.new(user: user, room: chat)
|
21
|
+
|
22
|
+
message.text ||= ''
|
23
|
+
msg = Lita::Message.new(robot, message.text, source)
|
24
|
+
|
25
|
+
robot.receive(msg)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
def send_messages(target, messages)
|
29
|
+
messages.each do |message|
|
30
|
+
client.api.sendChatAction(chat_id: target.room.to_i, action: 'typing')
|
31
|
+
client.api.sendMessage(chat_id: target.room.to_i, text: message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Lita.register_adapter(:telegram, self)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-telegram"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Rob McFadzean"]
|
5
|
+
spec.email = ["root@sphericalcube.net"]
|
6
|
+
spec.description = "Telegram handler for the Lita ChatOps framework"
|
7
|
+
spec.summary = "Allows Lita to connect to and handle messages from the Telegram bot framework/API"
|
8
|
+
spec.homepage = "https://github.com/wonderbread/lita-telegram"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "adapter" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.5"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "pry-byebug"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rack-test"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'telegram-bot-ruby'
|
26
|
+
end
|
data/locales/en.yml
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-telegram
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob McFadzean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: telegram-bot-ruby
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Telegram handler for the Lita ChatOps framework
|
112
|
+
email:
|
113
|
+
- root@sphericalcube.net
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/lita-telegram.rb
|
124
|
+
- lib/lita/adapters/telegram.rb
|
125
|
+
- lita-telegram.gemspec
|
126
|
+
- locales/en.yml
|
127
|
+
- spec/lita/adapters/telegram_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/wonderbread/lita-telegram
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata:
|
133
|
+
lita_plugin_type: adapter
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.5
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Allows Lita to connect to and handle messages from the Telegram bot framework/API
|
154
|
+
test_files:
|
155
|
+
- spec/lita/adapters/telegram_spec.rb
|
156
|
+
- spec/spec_helper.rb
|