Skip to content

Commit 08448f3

Browse files
author
Nicholas Chambers
committed
Initial commit. Project is in a very rough state.
1 parent 8e0284f commit 08448f3

File tree

4 files changed

+271
-0
lines changed

4 files changed

+271
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config.json
2+
config-dev.json

admins.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Enalicho
2+
intothev01d
3+
zzyzzyxx
4+
tangentstorm
5+
raylu
6+
darkf
7+
nchambers
8+
SirSkidmore
9+
Adrian17

bot.rb

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/usr/bin/env ruby
2+
3+
# tmp todo
4+
# ban
5+
# kick
6+
# quiet
7+
# unban
8+
# unquiet
9+
# add op
10+
# remove op
11+
# decloak
12+
13+
require 'cinch'
14+
require 'net/http'
15+
require 'json'
16+
17+
if ARGV[0] == nil then
18+
abort('usage: ./bot.rb [config file]')
19+
end
20+
21+
config = JSON.parse(File.open(ARGV[0], 'r').read)
22+
$factoids = {}
23+
$admins = []
24+
$channel_actions = {}
25+
26+
bot = Cinch::Bot.new do
27+
configure do |conf|
28+
conf.server = config['server']
29+
conf.port = config['port']
30+
31+
conf.messages_per_second = config['messages_per_second']
32+
conf.sasl.username = config['username']
33+
conf.sasl.password = config['password']
34+
conf.ssl.use = config['ssl']
35+
conf.channels = config['channels']
36+
conf.nick = config['nick']
37+
conf.realname = config['realname']
38+
conf.user = config['user']
39+
end
40+
41+
on :op do |msg, nick|
42+
if msg.user.nick == 'ChanServ' and nick == config['nick'] then
43+
for action in $channel_actions[msg.channel.name] do
44+
command, mask = action.split
45+
46+
case command
47+
when 'ban'
48+
Channel(msg.channel.name).ban(mask) unless mask == nil
49+
when 'quiet'
50+
msg.bot.irc.send "MODE #{msg.channel.name} +q #{mask}"
51+
when 'kick'
52+
Channel(msg.channel.name).kick(mask) unless mask == nil
53+
when 'unban'
54+
Channel(msg.channel.name).unban(mask) unless mask == nil
55+
when 'unquiet'
56+
msg.bot.irc.send "MODE #{msg.channel.name} -q #{mask}"
57+
end
58+
end
59+
60+
$channel_actions[msg.channel.name] = []
61+
Channel(msg.channel.name).deop config['nick']
62+
end
63+
end
64+
65+
on :message, /((http:\/\/)?pastebin\.com\/\S*)/ do |msg, pblink|
66+
uri = URI(pblink)
67+
paste = Net::HTTP.get(uri.host, "/raw#{uri.path}")
68+
69+
if paste != '' then
70+
res = Net::HTTP.post_form(URI('https://cpy.pt/'), 'paste' => paste, 'raw' => 'false')
71+
token, link = res.body.chomp.split('|')
72+
puts "[] Delete: #{token}"
73+
msg.reply "repasted for #{msg.user.nick} at #{link.lstrip}"
74+
else
75+
msg.reply "God damn it #{msg.user.nick}. That link isn't valid."
76+
end
77+
end
78+
79+
on :message, /\$set (\S*) is (.*)/ do |msg, factname, factvalue|
80+
$factoids[factname] = factvalue
81+
msg.reply "defined #{factname}"
82+
end
83+
84+
on :message, /\$show (\S*)/ do |msg, factname|
85+
msg.reply "#{$factoids[factname]}"
86+
end
87+
88+
on :message, /\$get (\S*)$/ do |msg, factname|
89+
if $factoids.key?(factname) then
90+
factopt = $factoids[factname].split(' | ')
91+
msg.reply "#{factopt[Random.rand(factopt.size)]}"
92+
end
93+
end
94+
95+
on :message, /\$get (\S*) for (\S*)/ do |msg, factname, user|
96+
if $factoids.key?(factname) then
97+
factopt = $factoids[factname].split(' | ')
98+
msg.reply "#{user}: #{factopt[Random.rand(factopt.size)]}"
99+
end
100+
end
101+
102+
on :message, /\$get rid of (\S*)/ do |msg, factname|
103+
factvalue = $factoids.delete factname
104+
msg.reply "Removed #{factname} -> #{factvalue}"
105+
end
106+
107+
on :message, '$list' do |msg|
108+
msg.reply "My current factoids are: #{$factoids.collect { |key, value| key }.join ', '}"
109+
end
110+
111+
on :message, /\$join (\S*)/ do |msg, channel|
112+
if $admins.include?(msg.user.authname) then
113+
Channel(channel).join
114+
end
115+
end
116+
117+
on :message, /\$part (\S*)/ do |msg, channel|
118+
if $admins.include?(msg.user.authname) then
119+
Channel(channel).part
120+
end
121+
end
122+
123+
# #<Cinch::Message @raw=":nchambers!nchambers@freenode/spooky-exception/bartender/learnprogramming.nchambers PRIVMSG ##eggnog :$kick nchambers" @params=["##eggnog", "$kick nchambers"] channel=#<Channel name="##eggnog"> user=#<User nick="nchambers">>
124+
125+
on :message, /\$(ban|quiet|kick|unban|unquiet) (\S*)$/ do |msg, action, mask|
126+
if $admins.include?(msg.user.authname) then
127+
if not $channel_actions.key? msg.channel.name then
128+
$channel_actions[msg.channel.name] = []
129+
end
130+
131+
$channel_actions[msg.channel.name].push "#{action} #{mask}"
132+
User('ChanServ').send("OP #{msg.channel.name}")
133+
end
134+
end
135+
136+
on :message, /\$(ban|quiet|kick|unban|unquiet) (\S*) (\S*)/ do |msg, action, channel, mask|
137+
if $admins.include?(msg.user.authname) then
138+
if not $channel_actions.key? channel then
139+
$channel_actions[channel] = []
140+
end
141+
142+
$channel_actions[channel].push "#{action} #{mask}"
143+
User('ChanServ').send("OP #{channel}")
144+
end
145+
end
146+
end
147+
148+
raw_factoids = File.open('factoids.txt', 'r').read
149+
150+
for line in raw_factoids.lines do
151+
factname, factvalue = line.chomp.split ' ', 2
152+
$factoids[factname] = factvalue
153+
end
154+
155+
$admins = File.open('admins.txt', 'r').read.lines.collect { |admin| admin.chomp }
156+
157+
at_exit do
158+
handle = File.open('factoids.txt', 'w')
159+
$factoids.each do |factname, factvalue|
160+
handle.puts "#{factname} #{factvalue}"
161+
end
162+
163+
handle = File.open('admins.txt', 'w')
164+
$admins.each do |admin|
165+
handle.puts "#{admin}"
166+
end
167+
end
168+
169+
bot.start

factoids.txt

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
pastebin pastebin.com is slow, adds whitespace, has adverts, is blocked for many people. Please use a more pleasant pastebin, such as http://ix.io , http://dpaste.de , http://lpaste.net , https://gist.github.com , https://cpy.pt/
2+
86-emu http://carlosrafaelgn.com.br/Asm86/
3+
cs <beingbrown> yeah. if you shift 8 of them, it's one byte
4+
pharpend https://www.youtube.com/watch?v=sBIEQOzZFNE | https://www.youtube.com/watch?v=g8EDjOesFH8 | [pharpend] I can't even stab myself without fucking up | [pharpend] I remember I was talking to a girl once, and she asked what I do for fun, and I replied "Oh I read about math and I program". The look on her face progressed from: 1. pure confusion to 2. disgust to 3. pity | <pharpend> the last time I tried to give someone maintainership I accidentally deleted the repo
5+
loop $get loop
6+
recursion Recursion is recursive. For more information, see $recursion
7+
compiles <Jon10> Huh, so it appears the issue only happens in release mode, doesn't occur in debug. | IT COMPILES???? SHIP IT!!!!!
8+
cookies Whenever you make a testcase, nchambers gives you a cookie
9+
projects https://www.raylu.net/httpd.txt | https://github.com/karan/Projects | https://gist.github.com/raylu/5c6d570ae186f963ad2d
10+
recruiting This is really not the place to be looking for work, people to do work, or a mentor.
11+
codepieces It's not up to you to decide what code is or is not relevant to your problem. Please make a full testcase.
12+
sysadmin https://www.reddit.com/r/linuxadmin/comments/2s924h/how_did_you_get_your_start/cnnw1ma?context=3 https://www.reddit.com/r/sysadmin/wiki/faq https://www.reddit.com/r/sysadmin/wiki/bootcamp https://www.reddit.com/r/sysadmin/wiki/index
13+
license http://choosealicense.com
14+
standards darkf has none | https://xkcd.com/927/
15+
problem-list http://www.ta-sa.org/2016/04/22/programming-problem-index.html
16+
gitguide http://rogerdudler.github.io/git-guide
17+
pictures Please. Do. Not. Post. Pictures. Of. Code.
18+
fangs <fangs124> WHERE DO ALL THESE EXTRA LINE COMMING FROM
19+
what What is the problem? What is confusing? What have you done?
20+
descriptive We aren't mind readers. Please explain exactly what your issue is. Also see $ask $pastebin and $testcase
21+
crystalball I will now predict your future. I am looking into my crystal ball, and see... see... what appears to be raylu, and he appears to be saying: "Write a shell"
22+
testcase A testcase is a minimal compilable example exhibiting your symptoms. "Minimal" means just the bare essentials required to illustrate your question. "Compilable" means that there is enough code to compile it on our machines, and therefore use our debuggers. Please paste a testcase at http://ideone.com or http://codepad.org to help us assist you. For a testcase checklist: http://eel.is/iso-c++/testcase/
23+
ask Don't ask to ask, skip the pleasantries and just ask your actual question.
24+
pedantic Technical language is not like everday speech where correcting a non-native speaker might be seen as impolite. Here it's absolutely necessary and should be seen as something neutral rather than rude or condescending.
25+
snowman ☃
26+
sqli http://bobby-tables.com
27+
spoonfeed "Having someone do certain things for you is like getting someone to chew your food for you. It might be easier to swallow but it loses all its flavor... And you want the flavor!"
28+
shrug ¯\_(ツ)_/¯
29+
lod ಠ_ಠ
30+
ls DO NOT USE ls' output for anything. ls is a tool for interactively looking at directory metadata. Any attempts at parsing ls' output with code are broken. Globs are much more simple AND correct: ''for file in *.txt''. Read http://mywiki.wooledge.org/ParsingLs
31+
qefs "$Quote" "$Every" "$Fucking" "$Substitution"
32+
[[ [[ is a bash keyword similar to (but more powerful than) the [ command. See <http://mywiki.wooledge.org/BashFAQ/031> and <http://mywiki.wooledge.org/BashGuide/TestsAndConditionals>. Unless you're writing for POSIX sh, we recommend [[.
33+
[ test or [ test is the POSIX test command. It can do simple tests on files and strings. In bash, you should use the more powerful [[ instead and ban [ for sake of consistency. [[ can do pattern matching, is faster and safer to use. http://mywiki.wooledge.org/BashGuide/TestsAndConditionals http://mywiki.wooledge.org/BashFAQ/031
34+
pe Parameter Expansion expands parameters: "$foo", "$1". You can use it to perform string or array operations: "${file%.mp3}", "${0##*/}", "${files[@]: -4}". They should *always* be quoted. See: http://mywiki.wooledge.org/BashFAQ/073 and "Parameter Expansion" in man bash. Also see http://wiki.bash-hackers.org/syntax/pe.
35+
html You can't parse tag-based languages like HTML or XML using bash, grep, sed, cut, etc. See http://mywiki.wooledge.org/BashFAQ/113 instead.
36+
xy http://mywiki.wooledge.org/XyProblem -- "I want to do X, but I'm asking how to do Y..."
37+
shellcheck ShellCheck is a shell linting/suggestion tool: http://www.shellcheck.net/
38+
alis We are not a channel listing service. Please see /msg alis help list
39+
roulette *click* | *click* | *click* | *click* | *click* | *BANG*
40+
rand int rand() { return 4; /* Chosen by dice roll. Guaranteed to be random. */ }
41+
2048-ai http://ov3y.github.io/2048-AI/
42+
algorithms http://bost.ocks.org/mike/algorithms/
43+
arcade https://archive.org/details/internetarcade
44+
connection-record 45
45+
cron <KindOne> "***** - Five star cron job. Will run again."
46+
42-cpp << reinterpret_cast<int(*)()>("\xB8\x2A\x00\x00\x00\xC3")();
47+
todo-list destroy usandfriends
48+
c-family <Fabtasticwill> japanese and html are a lot alike
49+
forkbomb :(){ :|:& };:
50+
guiippiadadui Globally universally interstellar intergalatic planetary planetary intergalatic another dimension another dimension unique identifier
51+
internet-shit <ResidentBiscuit> TCP = shit always gets there. UDP = shit may get there. NAT = Your shit is different to the rest of the world. IP = How people talk to your shit. Ports = How your shit talks to several other shits at once
52+
paths <ne555> /usr/include <nchambers> wrong OS ne555 <ne555> c:>\usr\include
53+
next Another satisfied customer... next!
54+
ngt Narcissistic Greeting Time, cuz we're fabulous.
55+
omega-pearls Java is almost 100% C++.
56+
projectmanagers think you can create a baby in 1 month with 9 women. Don't take it personally.
57+
life-lessons <TheRabbitologist> Stay in drugs and don't do school.
58+
threats <TheRabbitologist> If I ever meet you, I will tickle you.
59+
rb <TheRabbitologist> You wouldn't believe how awkward it was to get a keyboard up his mother's vagina so that he could do development work on weekends. | <ResidentBiscuit> Do you deliver to other states? I could use some pizza | frugality I more enjoy the act of brewing tea than actually drinking it. | Make an app. Get rich. Make bitches.
60+
rb-pr0n [ResidentBiscuit] I jerk it to chrome somedays
61+
rb-salsa Such good. So flavor. Very spice though.
62+
ru-int TheRabbitologist: Really unsigned int.
63+
shit-rabbit-says <TheRabbitologist> And, I'll need to set up all the signals/sluts for closing stuff.
64+
shit-tachyon-says <Tachyon> seriously, i almost want to be girl in order to fantasize about going out with him xD
65+
spoiler-alert The titanic sinks.
66+
sql <preaction> and as someone who's parsed html with SQL, it's a terrible idea
67+
typical-rabbit <TheRabbitologist> I also owned God for a year before that. It broke.
68+
ugt Universal Greeting Time, because the length of a day is socially-constructed.
69+
ub-solved #define BEHAVIOR /* there... now one can complain about undefined behavior */
70+
unicode-stuffz http://www.joelonsoftware.com/articles/Unicode.html
71+
usandf-creep <usandfriends> I am not fucking a creep.
72+
usand-lovelife <usandfriends> I dated this one compiler in my junior year. she kept obfuscating my dick!
73+
zalgo H̡e ̴w̴ho ͘wai̵t͠s beh̴įnd t̀h̀e ͠wall.̡ Z̠̗̼̥̍ͣͫͪ̇̄A̙̠̦͈̰͖ͫL̻̣̄ͮͭ̑̉ͤG̩̹O̰̯̭ͫ̆̋ͥ͂ͯ̏!̺̱̠̯̀̿ͮ
74+
backpack-hentai http://pastebin.com/pgrY6xU7
75+
ops darkf, darkfm, tangentstorm, raylu, adrian17, nchambers, dtscode, redlizard, taylskid
76+
brainfuck http://www.muppetlabs.com/~breadbox/bf/
77+
syn ack
78+
apple 
79+
pear The cake is a lie
80+
pick 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
81+
usandbio system grandma
82+
ipfs https://ipfs.io/
83+
pingfs https://github.com/yarrick/pingfs
84+
help you are beyond help. | no | 42
85+
tias Try it and see!
86+
seniority a measurement of how long you've been wrong.
87+
ts-solution https://cpy.pt/2aH92hRh
88+
doesntwork How doesn't it work? Be descriptive.
89+
file-count echo $(( `ls -l | awk '{ print $9; }' | cat | cat | cat | wc -l` - 1 ))
90+
hi hello
91+
ping pong

0 commit comments

Comments
 (0)