cinch-cleverbotredux 1.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.
data/.gitattributes ADDED
@@ -0,0 +1,22 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+
4
+ # Custom for Visual Studio
5
+ *.cs diff=csharp
6
+ *.sln merge=union
7
+ *.csproj merge=union
8
+ *.vbproj merge=union
9
+ *.fsproj merge=union
10
+ *.dbproj merge=union
11
+
12
+ # Standard to msysgit
13
+ *.doc diff=astextplain
14
+ *.DOC diff=astextplain
15
+ *.docx diff=astextplain
16
+ *.DOCX diff=astextplain
17
+ *.dot diff=astextplain
18
+ *.DOT diff=astextplain
19
+ *.pdf diff=astextplain
20
+ *.PDF diff=astextplain
21
+ *.rtf diff=astextplain
22
+ *.RTF diff=astextplain
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Cinch-CleverBotRedux
2
+
3
+ ## Description
4
+
5
+ A very simple plugin which provides an interface between the Cleverbot webserver, and Cinch. It comes with a number of features, including the option for Channel operators to disable the bot's CleverBot functions for that specific channel.
6
+
7
+ <User> CleverBot: how would I even be able to answer that
8
+ <CleverBot> User: By saying dirk strider.
9
+ <User> CleverBot: dirk strider
10
+ <CleverBot> User: Dave Strider loves Dirk Strider.
11
+ <User> CleverBot: Yes. Also, ur a homestuck
12
+ <CleverBot> User: With courage I will face.
13
+
14
+ ## Installation
15
+
16
+ ### RubyGems
17
+
18
+ You can install the latest Cinch-CleverBot gem using RubyGems
19
+
20
+ gem install cinch-cleverbotredux
21
+
22
+ ### GitHub
23
+
24
+ You can also get the most up to date code directly from Github
25
+
26
+ git clone http://github.com/curiouslyExistential/cinch-cleverbotredux.git
27
+
28
+ ## Usage
29
+
30
+ The following commands are available:
31
+
32
+ !disablechatter
33
+ This command, when used by anyone with Voice or higher,
34
+ will disable the bot's CleverBot interface on that specific channel.
35
+
36
+ !enablechatter
37
+ This is used to re-enable the bot's CleverBot interface on said channel.
38
+ It has the same permissions as the disable command.
39
+
40
+ !globaldisable
41
+ This command can only be used by the botmaster (This must be changed in the plugin's coding.
42
+ I made sure that it's easy to fight, right up top.)
43
+ This command will globally disable the CleverBot interface.
44
+
45
+ !globalenable
46
+ This command contains the same permissions as globaldisable.
47
+ It is used to re-enable the interface.
48
+ Please note that this will not reset any restriction that a channel operator has imposed on the bot
49
+ with the previous commands.
50
+
51
+ Install the gem and load it in your Cinch bot:
52
+
53
+ require "cinch"
54
+ require "cinch/plugins/cleverbot"
55
+
56
+ bot = Cinch::Bot.new do
57
+ configure do |c|
58
+ # Add all required options here
59
+ c.plugins.plugins = [CleverBotRedux] # Optionally add more plugins
60
+ end
61
+ end
62
+
63
+ bot.start
64
+
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "cinch-cleverbotredux"
5
+ s.version = "1.0"
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Dorion Beaudin"]
8
+ s.email = ["dorionbeaudin@live.ca"]
9
+ s.homepage = "https://github.com/curiouslyExistential/cinch-cleverbotredux.git"
10
+ s.summary = %q{Provides a simple to use IRC <-> Cleverbot interface}
11
+ s.description = %q{This plugin contains an interface to permit users to interact with Cleverbot. It also contains several admin-friendly functions, should the bot become annoying on a channel.}
12
+
13
+ s.add_dependency("cinch", "~> 2.1.0")
14
+ s.add_dependency("cleverbot", "~> 0.2.0")
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.require_paths = ["lib"]
18
+ end
@@ -0,0 +1,91 @@
1
+ require 'cinch'
2
+ require 'cleverbot'
3
+ require 'set'
4
+
5
+ class CleverBotRedux
6
+ include Cinch::Plugin
7
+
8
+ match lambda { |m| /^#{m.bot.nick}: (.+)/i }, use_prefix: false
9
+ match "disablechatter", use_prefix: true, method: :disableChanChat
10
+ match "enablechatter", use_prefix: true, method: :enableChanChat
11
+ match "globaldisable", use_prefix: true, method: :globalDisable
12
+ match "globalenable", use_prefix: true, method: :globalEnable
13
+ match "chatterhelp", use_prefix: true, method: :chatterHelp
14
+
15
+ def initialize(*args)
16
+ super
17
+ @admins = ["cExistential"]
18
+ @enabled = true
19
+ @prefixUse = true
20
+ @disabledChannels = Set.new
21
+ @cleverbot = Cleverbot::Client.new
22
+ end
23
+
24
+ def execute(m, message)
25
+ return unless @enabled
26
+ if @disabledChannels.include?(m.channel)
27
+ return
28
+ else
29
+ if m.channel
30
+ msg_back = @cleverbot.write message
31
+ m.reply(msg_back, @prefixUse)
32
+ end
33
+ end
34
+ end
35
+
36
+ def chatterHelp(m)
37
+ m.reply("Available commands for privileged users (voice and up): ~disablechatter, ~enablechatter", @prefixUse)
38
+ end
39
+
40
+ def disableChanChat(m)
41
+ if m.channel.opped?(m.user) or m.channel.half_opped?(m.user) or m.channel.voiced?(m.user)
42
+ if @disabledChannels.add?(m.channel) == nil
43
+ m.reply("CleverBot already disabled.", @prefixUse)
44
+ return
45
+ else
46
+ m.reply("CleverBot disabled.", @prefixUse)
47
+ @disabledChannels + ["#{m.channel}"]
48
+ return
49
+ end
50
+ end
51
+ end
52
+
53
+ def enableChanChat(m)
54
+ if m.channel.opped?(m.user) or m.channel.half_opped?(m.user) or m.channel.voiced?(m.user)
55
+ if @disabledChannels.delete?(m.channel) == nil
56
+ m.reply("CleverBot already enabled.", @prefixUse)
57
+ return
58
+ else
59
+ m.reply("CleverBot enabled.", @prefixUse)
60
+ @disabledChannels - ["#{m.channel}"]
61
+ return
62
+ end
63
+ end
64
+ end
65
+
66
+ def globalDisable(m)
67
+ return unless check_user(m.user)
68
+ if @enabled == true
69
+ @enabled = false
70
+ m.reply("CleverBot is now globally disabled.", @prefixUse)
71
+ else
72
+ m.reply("CleverBot is already globally disabled.", @prefixUse)
73
+ end
74
+ end
75
+
76
+ def globalEnable(m)
77
+ return unless check_user(m.user)
78
+ if @enabled == false
79
+ @enabled = true
80
+ m.reply("CleverBot is now globally enabled.", @prefixUse)
81
+ else
82
+ m.reply("CleverBot is already globally enabled.", @prefixUse)
83
+ end
84
+ end
85
+
86
+ def check_user(user)
87
+ user.refresh # be sure to refresh the data, or someone could steal
88
+ # the nick
89
+ @admins.include?(user.authname)
90
+ end
91
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-cleverbotredux
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dorion Beaudin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-04 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cinch
16
+ requirement: &21633792 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *21633792
25
+ - !ruby/object:Gem::Dependency
26
+ name: cleverbot
27
+ requirement: &21633504 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *21633504
36
+ description: This plugin contains an interface to permit users to interact with Cleverbot.
37
+ It also contains several admin-friendly functions, should the bot become annoying
38
+ on a channel.
39
+ email:
40
+ - dorionbeaudin@live.ca
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitattributes
46
+ - .gitignore
47
+ - Gemfile
48
+ - README.md
49
+ - cinch-cleverbotredux.gemspec
50
+ - lib/cinch/plugins/cleverbotredux.rb
51
+ homepage: https://github.com/curiouslyExistential/cinch-cleverbotredux.git
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.7.2
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Provides a simple to use IRC <-> Cleverbot interface
75
+ test_files: []