Cinch-Tell 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: a56bede95d10981553c8b63a7eaadbeb41be3dd7
4
- data.tar.gz: 6c4754c10182a6b27ec64263727abeb428899d1c
3
+ metadata.gz: 35e8cea7fd8e9036ac37189981efd9e655b7a4e4
4
+ data.tar.gz: d50246c1b4b1a593395c741f10d8a5ce1b77ade1
5
5
  SHA512:
6
- metadata.gz: eef02982dfd295b89c84810d26f283c8100a8148b432429fbdbe9f143fe2d8b5959067747536a98a8e621e725cd6105bd23bedd2b335efc56ea7dc672124cb1f
7
- data.tar.gz: 4993775663ba8a4eb5cb163520b8d48dd6f5c3cb6412dce03aab68b506d2e81c8268541f14c9bcaec0d5fe1c44b5c04aa32265217e5d6762fa99076d13a20b69
6
+ metadata.gz: e51c31376a35d3627ba0c1d18629a1f2ca7b57595a061ec47d8777ac398309db3cecb66e54a9c3fdfe3e472cfc724e6de0ad841abaabcef578ae4a440e1fa14b
7
+ data.tar.gz: 5f74ac931e1eec12ca5de38874e632cc4b997feb9e02a8bc8f6a13d58861bfda31cc35b4f67b4537af4946c831270dea88e60ad01d8433029250fb4a837a8381
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Lily Jónsdottír / Lily Seki
3
+ Copyright (c) 2016 Lily Jónsdóttir / Lily Seki
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  module Cinch
2
2
  module Tell
3
- VERSION = '0.0.4'.freeze
3
+ VERSION = '0.0.5'.freeze
4
4
  end
5
5
  end
@@ -18,10 +18,14 @@ module Cinch
18
18
  listen_to :join, method: :check_tells
19
19
  listen_to :nick, method: :check_tells
20
20
 
21
+ # I don't actually know if this does anything with cinch
22
+ # but I keep anything that's not an actual command private
21
23
  private
22
24
 
23
25
  def initialize(*args)
24
26
  super
27
+ # TODO: make database name based on bot nick
28
+ # or configuration variable
25
29
  @db = Sequel.sqlite('riria.db')
26
30
  # Create the tables if they don't exist
27
31
  @db.create_table? :tells do
@@ -34,11 +38,8 @@ module Cinch
34
38
  @db = purge_ancients(@db)
35
39
  end
36
40
 
37
- def header(title)
38
- puts '=' * 5 + " #{title} " + '=' * 5
39
- end
40
-
41
41
  def read_tells(nick)
42
+ # read the database and return array of tells for specified nick
42
43
  tells = @db[:tells]
43
44
  ret = tells.where(to_user: nick).all
44
45
  return [] if ret.empty?
@@ -47,7 +48,6 @@ module Cinch
47
48
 
48
49
  def parse_tells(tell)
49
50
  # ready tell for telling
50
- to_nick = tell[:to_user]
51
51
  from_nick = tell[:from_user]
52
52
  msg = tell[:message]
53
53
  msg_when = tell[:time]
@@ -65,17 +65,18 @@ module Cinch
65
65
  ago_str << 'ago.' unless ago_str.empty?
66
66
  ago_str = 'an undetermined amount of time ago.' if ago_str.empty?
67
67
  output << ago_str
68
- # feels odd without "return output" but I guess that's Ruby
69
68
  end
70
69
 
71
70
  def purge_ancients(db)
72
71
  # purge any messages older than x date
72
+ # TODO: make this a config variable
73
73
  purge_date = Time.now.shift(-6, :months)
74
74
  db[:tells].where('time < ?', purge_date.to_f).delete
75
75
  db
76
76
  end
77
77
 
78
78
  def add_tell(nick, msg, from)
79
+ # add a tell to the database
79
80
  t = Time.now.to_f
80
81
  @db[:tells].insert(to_user: nick, from_user: from, message: msg, time: t)
81
82
  end
@@ -83,6 +84,11 @@ module Cinch
83
84
  public
84
85
 
85
86
  def check_tells(m)
87
+ # Listen to join and nick changes, and check if user has any waiting
88
+ # memos in the database. Might listen to all messages and check if
89
+ # speaking user has any waiting memos, for people who go away
90
+ # but don't change their nick, but I'm not sure if I want to query
91
+ # the database at every IRC message in every channel
86
92
  tells = read_tells(m.user.nick.downcase)
87
93
  return if tells.empty?
88
94
  r = parse_tells(tells.first)
@@ -94,7 +100,7 @@ module Cinch
94
100
  User(i[:to_user]).send(parse_tells(i))
95
101
  end
96
102
  end
97
- @db[:tells].where(to_user: m.user.nick).delete
103
+ @db[:tells].where(to_user: m.user.nick.downcase).delete
98
104
  end
99
105
 
100
106
  match(/tell(?: (.+))?/, method: :irc_tell)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Cinch-Tell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lily Jónsdóttir