telepost 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba5f7eb9ca2541557776464020da4ff32eb59672585dec56005727ee88570471
4
- data.tar.gz: f699e2b454615c3f8534371c0ee7cc81201e0c931195f6611c330eac8f971ca3
3
+ metadata.gz: 4f0360cb45f6d5abf53b648426caf61f8c4b05189a732b69285b80fa72a9a391
4
+ data.tar.gz: b58854a54ed8641963808b22922abd1228013eca6b676efe3a8e722877083746
5
5
  SHA512:
6
- metadata.gz: 3e09b438f36303b10fa9a14d7d63f63d79c6edcde32c6aceb9bfa1044cf085b6a6ee04a5283b8538bda2cdf43301d8cdc43400b7fec95d8ba42ce39f75c9b2fd
7
- data.tar.gz: d75997905404f05aed34490ce6b0f7dfbedb50f12afa347178df12de03d0efb261b175fb954bb88566d247606b73a95c7897c7ebf03b95ce77f1116cf8a94f02
6
+ metadata.gz: 4952e2ff2de28cd7d6d45a095d8b3de38de1e8eac6456237064a1ad5acb5b03304586dd8392ea16361274a0f442ddcba4a66e446bf06c5ea773bbc085f8fc57b
7
+ data.tar.gz: bb10d98baf1c103a71b773332b78023468ecc04238831d8965e29bca3d2583469d586d6ca396585eecb9410b10d791ee7b5754e17ce8deaa3e81279327f1a73d
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.3
3
+ - 2.5.1
4
4
  branches:
5
5
  only:
6
6
  - master
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![Build Status](https://travis-ci.org/yegor256/telepost.svg)](https://travis-ci.org/yegor256/telepost)
6
6
  [![Gem Version](https://badge.fury.io/rb/telepost.svg)](http://badge.fury.io/rb/telepost)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/5528e182bb5e4a2ecc1f/maintainability)](https://codeclimate.com/github/yegor256/telepost/maintainability)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/21aec58faee3866bdfbb/maintainability)](https://codeclimate.com/github/yegor256/telepost/maintainability)
8
8
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/telepost/master/frames)
9
9
 
10
10
  Telepost is a simple gateway to Telegram, which can post messages and respond to primitive requests.
@@ -21,8 +21,10 @@ Then, use it like this:
21
21
  require 'telepost'
22
22
  require 'logger'
23
23
  tp = Telepost.new('..token..')
24
- tp.run do |chat, msg|
25
- tp.post(chat: chat, 'Thanks for talking to me!')
24
+ Thread.start do
25
+ tp.run do |chat, msg|
26
+ tp.post(chat: chat, 'Thanks for talking to me!')
27
+ end
26
28
  end
27
29
  tp.post(chat: 12345, 'How are you?', 'How are you doing?')
28
30
  ```
@@ -51,15 +51,19 @@ class Telepost
51
51
  # Nothing to do here
52
52
  end
53
53
 
54
- def post(*lines, chat: 0)
54
+ def spam(*lines)
55
+ post(0, lines)
56
+ end
57
+
58
+ def post(chat, *lines)
55
59
  @sent << "#{chat}: #{lines.join(' ')}"
56
60
  end
57
61
  end
58
62
 
59
- def initialize(token, chat: 0)
63
+ def initialize(token, chats: [])
60
64
  @token = token
61
65
  @client = Telebot::Client.new(token)
62
- @chat = chat
66
+ @chats = chats
63
67
  end
64
68
 
65
69
  def run
@@ -75,8 +79,13 @@ class Telepost
75
79
  end
76
80
  end
77
81
 
78
- def post(*lines, chat: @chat)
79
- raise 'Default chat ID is not provided in the constuctor' if chat.zero?
82
+ def spam(*lines)
83
+ @chats.each do |chat|
84
+ post(chat, lines)
85
+ end
86
+ end
87
+
88
+ def post(chat, *lines)
80
89
  @client.send_message(
81
90
  chat_id: chat,
82
91
  parse_mode: 'Markdown',
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.5.1'
32
32
  s.required_ruby_version = '>=2.5'
33
33
  s.name = 'telepost'
34
- s.version = '0.1.0'
34
+ s.version = '0.2.0'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'Simple Telegram posting Ruby gem'
37
37
  s.description = 'Simple Telegram posting Ruby gem'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telepost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-08 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: telebot