chatx 0.0.0.pre.pre3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9cc5eac4b2cb23bd725fc867b2f9fca4ac7376c1bc6c9e9ac282d0914d0e0192
4
+ data.tar.gz: bee11dafb91d70ab00a3ac536da183289941cd8e69a823e7b53a060fd25e91a6
5
+ SHA512:
6
+ metadata.gz: a9b73297e51bf6bced36b85be3863d7939f53389e5ec49d2a76a1c684d4f80800d94a11f380ac45a51141af8871626c46b4f3be637d180a150636a7cf782e77d
7
+ data.tar.gz: db034d9d9525a8d2da916924f793cf1f2ad1ff1aff92ea66fa6c685b212e27a9d1c38bdbbeaef11c1380b35c11fadee374addd05fd9102d3746e1a3c05f98324
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.ruby-version
11
+ .idea/
12
+ *.log
@@ -0,0 +1,27 @@
1
+ before_script:
2
+ - gem install bundler --no-ri --no-rdoc
3
+ - bin/setup
4
+
5
+ test:2.1:
6
+ image: ruby:2.1
7
+ script:
8
+ - bundle exec rake test
9
+
10
+ test:2.2:
11
+ image: ruby:2.2
12
+ script:
13
+ - bundle exec rake test
14
+
15
+ test:2.3:
16
+ image: ruby:2.3
17
+ script:
18
+ - bundle exec rake test
19
+
20
+ test:2.4:
21
+ image: ruby:2.4
22
+ script:
23
+ - bundle exec rake test
24
+
25
+ rubocop:
26
+ script:
27
+ - rubocop -D
@@ -0,0 +1,38 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ ExtraDetails: true
4
+ Exclude:
5
+ - "chatx.gemspec"
6
+ - "Rakefile"
7
+ - "test/*"
8
+
9
+ Style/StringLiterals:
10
+ Enabled: false
11
+
12
+ Metrics/LineLength:
13
+ Max: 145
14
+ Enabled: false
15
+
16
+ Metrics/MethodLength:
17
+ Max: 35
18
+
19
+ Metrics/ClassLength:
20
+ Enabled: false
21
+
22
+ Metrics/AbcSize:
23
+ Enabled: false
24
+
25
+ Style/Documentation:
26
+ Enabled: false
27
+
28
+ Layout/SpaceInsideHashLiteralBraces:
29
+ Enabled: false
30
+
31
+ Style/NumericLiterals:
32
+ Enabled: false
33
+
34
+ Style/FrozenStringLiteralComment:
35
+ Enabled: false
36
+
37
+ Metrics/CyclomaticComplexity:
38
+ Enabled: false
@@ -0,0 +1 @@
1
+ --type-name-tag keyword:"Keyword Arguments"
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at isaiah@developingtechnician.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
21
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ # with Minitest::Spec
25
+ # watch(%r{^spec/(.*)_spec\.rb$})
26
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
+
29
+ # Rails 4
30
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
+ # watch(%r{^test/.+_test\.rb$})
36
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
+
38
+ # Rails < 4
39
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 izwick-schachter
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.
@@ -0,0 +1,141 @@
1
+ # ChatX
2
+
3
+ ChatX is a shorter and better and more ruby version of the ChatExchange python library for interacting with
4
+ Stack Exchange Chat, Stack Overflow Chat, and Meta Stack Exchange Chat.
5
+
6
+ The first thing to do is to go and make a chat account on the servers you want to use. Then, you can start with this
7
+ gem.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'chatx'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install chatx
24
+
25
+ ## Usage
26
+
27
+ The first thing you need is to create a new `ChatBot` and tell it what username you used, the password you used. If you
28
+ want it to operate on a site besides chat.stackexchange.com, you'll have to specify it:
29
+
30
+ ```ruby
31
+ my_chatbot = ChatBot.new("smartbot@example.com", "correct horse battery staple")
32
+ ```
33
+
34
+ If you want to improve your security a bit further, you could also get the username and password from environment
35
+ variables:
36
+
37
+ ```bash
38
+ $ export CXUsername=smartbot@example.com
39
+ $ export CXPassword="correct horse battery staple"
40
+ ```
41
+ ```ruby
42
+ my_chatbot = ChatBot.new(ENV["CXUsername"], ENV["CXPassword"])
43
+ ```
44
+ If you wanted to run it on a different server, you'd pass that server as the third argument to `ChatBot.new`. The
45
+ servers are given as either "stackexchange", "meta.stackexchange" or "stackoverflow".
46
+
47
+ To speak, the bot has a `say` method. For example, to have your chatbot say "Hello World" in the room with ID 1, you
48
+ would run `my_chatbot.say 1, "Hello World"`.
49
+
50
+ The recommended way to interact with chat is through "hooks". Hooks are a way of responding to actions in chat. For
51
+ example, if you wanted to have it reply to the message "!!/alive" in room 1 with "Yup, I'm here" you could create a
52
+ hook for the "message" event:
53
+
54
+ ```ruby
55
+ my_chatbot.add_hook 1, "message" do
56
+ say "Yup, I'm here"
57
+ end
58
+ ```
59
+
60
+ Or, if you wanted to make that a reply to the "!!/alive" message, you could do:
61
+
62
+ ```ruby
63
+ my_chatbot.add_hook 1, "message" do |msg|
64
+ msg.reply "Yup, I'm here"
65
+ end
66
+ ```
67
+
68
+ Here's a complete list of events that you can add a hook to:
69
+
70
+ ```
71
+ "message"
72
+ "edit"
73
+ "entrance"
74
+ "exit"
75
+ "rename"
76
+ "star"
77
+ "debug"
78
+ "mention"
79
+ "flag"
80
+ "delete"
81
+ "file"
82
+ "mod-flag"
83
+ "settings"
84
+ "gnotif"
85
+ "level"
86
+ "lnotif"
87
+ "invite"
88
+ "reply"
89
+ "move-out"
90
+ "move-in"
91
+ "time"
92
+ "feed"
93
+ "suspended"
94
+ "merged"
95
+ ```
96
+
97
+ The recommended way to add hooks is though the `gen_hooks` method, together with the room method:
98
+
99
+ ```ruby
100
+ my_chatbot.gen_hooks do
101
+ room 63296 do
102
+ on "mention" do |e|
103
+ e.reply "Right!" if e.body.downcase.end_with?("right?")
104
+ end
105
+
106
+ on "message" do |e|
107
+ if e.body.downcase.start_with?("@smelly good")
108
+ tod = e.body.split(" ")[2].gsub(/[^a-zA-Z]/, "")
109
+ e.reply "Good #{tod} to you as well!"
110
+ end
111
+ end
112
+ end
113
+ end
114
+ ```
115
+
116
+ Also, your hooks won't be active until you manually join the relevant rooms with `my_chatbot.join_room(1)`, and they'll
117
+ stop being active when you leave the room with `my_chatbot.leave_room(1)`.
118
+
119
+ ## Development
120
+
121
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
122
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
123
+
124
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
125
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
126
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
127
+
128
+ ## Contributing
129
+
130
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/izwick-schachter/ChatX. This project is
131
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
132
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
133
+
134
+ ## License
135
+
136
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
137
+
138
+ ## Code of Conduct
139
+
140
+ Everyone interacting in the ChatX project’s codebases, issue trackers, chat rooms and mailing lists is expected to
141
+ follow the [code of conduct](https://github.com/[USERNAME]/chatx/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "chatx"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,52 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "chatx/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chatx"
8
+ spec.version = ChatBot::VERSION
9
+ spec.authors = ["izwick-schachter"]
10
+ spec.email = ["isaiah@developingtechnician.com"]
11
+
12
+ spec.summary = %q{A bot. For the chat. This bot is a ruby way to chat with other
13
+ people on chat.stackexchange.com, chat.meta.stackexchange.com, or chat.stackoverflow.com}
14
+ spec.description = %q{A chatbot! For SE! In ruby!}
15
+ spec.homepage = "https://gitlab.com/izwick-schachter/chatx"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.15"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "minitest", "~> 5.0"
37
+ spec.add_development_dependency "rubocop", "~> 0.49"
38
+ spec.add_development_dependency "yard", "~> 0.9"
39
+ spec.add_development_dependency 'byebug', '~> 9.0'
40
+ spec.add_development_dependency 'guard', '~> 2.14'
41
+ spec.add_development_dependency 'guard-minitest', '~> 2.4'
42
+
43
+ [
44
+ ["mechanize", "~> 2.7"],
45
+ ["nokogiri", "~> 1.8"],
46
+ ["permessage_deflate", "~> 0.1"],
47
+ ["websocket-driver", "~> 0.6"],
48
+ ["htmlentities", "~> 4.3"]
49
+ ].each do |g, v|
50
+ spec.add_runtime_dependency g, v
51
+ end
52
+ end