monsternet 0.1.0 → 0.1.1

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: 1f91b7303b45dba986e13122cf8405150e25249ff17f8802d73ae02f999583d0
4
- data.tar.gz: a61f1415be13f65a067a5d47f8b7f52c313e2781d27c94c12da17bf913e818fb
3
+ metadata.gz: 16b172af07cc4b40b932a98ec3a8c00fa658de5e17a4506aef03c76b7a84534b
4
+ data.tar.gz: 697a565b973b55811cf20b8dc98817bcccf9adf1e85ae426ab75524f80340449
5
5
  SHA512:
6
- metadata.gz: 047dbbfb36963bd488257154b0d6348b61ac879c520289e39074eb56dc030bab71e716fa137f1120a2c0435c6fe705da4ae69cfe0869fdd5df9bcb9d475d5660
7
- data.tar.gz: 920c8057adfe7cbfbc1dc259c9e7b5290840291324d751d62cf257b418131a34e424c85262c36465213f48944672d9c2cae5e814e8bbdaa8e26e7415f858eb8f
6
+ metadata.gz: 37a93e3638989db7bf61b385499598466be246344647a35b103165607da743c5d78925956b21b648bc3d314f18eeb50b501e11c55214f48f0c1ad1f418220adf
7
+ data.tar.gz: a519c5c4d780483660e2f30b35df72685689a1dcd38c02af53b1366463b5ec790b196038e761149b5b012355590162029562a78d9ac635c9e5a731927fdb582a
data/README.md CHANGED
@@ -1,37 +1,28 @@
1
1
  # Monsternet
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/monsternet`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Install the gem and add to the application's Gemfile by executing:
10
-
11
- $ bundle add monsternet
12
-
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
-
15
- $ gem install monsternet
16
-
17
- ## Usage
18
-
19
- TODO: Write usage instructions here
20
-
21
- ## Development
22
-
23
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
-
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
-
27
- ## Contributing
28
-
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/monsternet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/monsternet/blob/master/CODE_OF_CONDUCT.md).
30
-
31
- ## License
32
-
33
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
-
35
- ## Code of Conduct
36
-
37
- Everyone interacting in the Monsternet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/monsternet/blob/master/CODE_OF_CONDUCT.md).
2
+ - install: `git clone https://github.com/xorgnak/monsternet && cd monsternet && ./monsternet [nickname]`
3
+
4
+ - Quick Start (in no particular order):
5
+ - Announce yourself on the network: `hi`
6
+ - Say "Hi!" to everyone on the server: `yell "Hi!"`
7
+ - Message a user: `yo 'username', "Your message."`
8
+ - View a user's profile: `look 'username'`
9
+ - Perform an action: `act 'username', 'action', number: 1, string: "a string", boolean: true, symbol: :sym, array: [ 1, "abc", :symbol, true ]`
10
+ - Quit: `bye`
11
+
12
+ ## Monster (Bots) Events - monster.rb
13
+ ```
14
+ EV[:hi] = lambda() { |peer| puts "#{peer} arrived" }
15
+ EV[:sup] = lambda() { |peer| puts %[#{peer} peered] }
16
+ EV[:yo] = lambda() { |peer, msg| puts "#{peer} said #{msg}" }
17
+ EV[:bye] = lambda() { |peer| puts "#{peer} left" }
18
+ EV[:get] = lambda() { |peer, page, params| puts %[#{peer} got #{page} with #{params}] },
19
+ EV[:new] = lambda() { |id, nick, peer| puts %[NEW CIRCUIT> #{id} #{nick} #{peer}] },
20
+ EV[:peer] = lambda() { |id, nick, peer| puts %[NEW PEER> #{id} #{nick} #{peer}] },
21
+ EV[:act] = lambda() { |body| puts %[FETCH>\n#{body}]; nil },
22
+ EV[:help] = lambda() { |h| h }
23
+ ```
24
+
25
+ ## Other Files:
26
+ - peers.txt: a list of peer to connect to.
27
+ - uuid.txt: a static generated uuid.
28
+ - attr.json: a json dictionary of attributes.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Monsternet
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/monsternet.rb CHANGED
@@ -18,7 +18,7 @@ UUID_FILE = 'uuid.txt'
18
18
  PEERS_FILE = 'peers.txt'
19
19
  PAGES_DIR = "#{Dir.pwd}/pages"
20
20
 
21
- if !File.exists?(UUID_FILE)
21
+ if !File.exist?(UUID_FILE)
22
22
  _id = []
23
23
  8.times { _id << rand(16).to_s(16) }
24
24
  File.open(UUID_FILE, 'w') { |f| f.write(_id.join("")) }
@@ -42,6 +42,7 @@ if File.exist?(PEERS_FILE)
42
42
  File.readlines(PEERS_FILE).each do |line|
43
43
  $known_peers << line.strip unless line.strip.empty?
44
44
  end
45
+ #File.open(PEERS_FILE, 'w') { |f| f.write(@known_peers.to_a.join("\n")) }
45
46
  end
46
47
 
47
48
  EV = Hash.new { |h,k| h[k] = lambda() { |*a| puts %[EV> #{k} #{a}] } }
@@ -272,67 +273,69 @@ module MON
272
273
  end
273
274
 
274
275
  class Monster
275
- def initialize
276
- if !File.exist?(ATTR_FILE)
277
- File.open(ATTR_FILE, 'w') { |f| f.write(JSON.generate({})) }
278
- end
279
- @attr = JSON.parse(File.read(ATTR_FILE))
280
- MON.init!
281
- end
282
- def attr
283
- @attr
284
- end
285
- def save
286
- File.open(ATTR_FILE, 'w') { |f| f.write(JSON.generate(@attr)) }
287
- return 'OK'
288
- end
289
- def id
290
- ID
291
- end
292
- def nick
293
- NICK
294
- end
295
- def peers
296
- MON.nicks.keys
297
- end
298
- def yo k, m
299
- MON.yo(k, m)
300
- end
301
- def yell m
302
- peers.each { |e| yo(e, m) }
303
- end
304
- def act k, x, h={}
305
- EV[:act].call(MON.get(k, "#{x}.erb", h))
306
- end
307
- def look k
308
- act(k, 'index', @attr)
309
- end
310
- def me
311
- my_info
312
- end
313
- def hi
314
- MON.hi!
315
- end
316
- def bye
317
- MON.bye!
318
- exit
319
- end
320
- def methods
321
- [ :id, :nick, :attr, :peers, :yo, :yell, :act, :look, :me, :save, :hi, :bye, :help ]
322
- end
323
- def help
324
- EV[:help].call({
325
- id: "Your id",
326
- nick: "Your nick",
327
- attr: "Your attributes",
328
- peers: "Known Peers",
329
- yo: "Send NICK MESSAGE",
330
- yell: "Send all MESSAGE",
331
- act: "Fetch PEER INDEX",
332
- look: "Fetch PEER index.erb with attributes",
333
- me: "Your host",
334
- save: "Save your attributes",
335
- hi: "Announce to peers",
336
- bye: "Leave peers and quit" })
337
- end
276
+ def initialize
277
+ @methods = []
278
+ @help = {}
279
+ if !File.exist?(ATTR_FILE)
280
+ File.open(ATTR_FILE, 'w') { |f| f.write(JSON.generate({})) }
281
+ end
282
+ @attr = JSON.parse(File.read(ATTR_FILE))
283
+ MON.init!
284
+ end
285
+ def attr
286
+ @attr
287
+ end
288
+ def save
289
+ File.open(ATTR_FILE, 'w') { |f| f.write(JSON.generate(@attr)) }
290
+ return 'OK'
291
+ end
292
+ def id
293
+ ID
294
+ end
295
+ def nick
296
+ NICK
297
+ end
298
+ def ls
299
+ MON.nicks.keys
300
+ end
301
+ def yo k, m
302
+ MON.yo(k, m)
303
+ end
304
+ def post k, x, h={}
305
+ EV[:act].call(MON.get(k, "#{x}.erb", h))
306
+ end
307
+ def get k
308
+ post(k, 'index', @attr)
309
+ end
310
+ def me
311
+ my_info
312
+ end
313
+ def hi *m
314
+ MON.hi!
315
+ if m[0]
316
+ peers.each { |e| yo(e, m[0]) }
317
+ return "OK"
318
+ end
319
+ end
320
+ def bye
321
+ MON.bye!
322
+ exit
323
+ end
324
+ def methods
325
+ [ @methods, :id, :nick, :attr, :ls, :yo, :post, :get, :me, :save, :hi, :bye, :help ].flatten.compact
326
+ end
327
+ def help
328
+ EV[:help].call({
329
+ id: "Your id.",
330
+ nick: "Your nick.",
331
+ attr: "Your attributes.",
332
+ ls: "Known Peers.",
333
+ yo: "Send NICK MESSAGE.",
334
+ get: "Fetch PEER :index.",
335
+ post: "Fetch PEER :index with attributes.",
336
+ me: "Your host.",
337
+ save: "Save your attributes.",
338
+ hi: "Announce to peers with optional message.",
339
+ bye: "Leave peers and quit" }.merge(@help))
340
+ end
338
341
  end
data/monster.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'pedicab'
2
+ require 'toychest'
3
+
4
+ # pedicab.rb events
5
+ EV[:cab] = lambda { |i| i.split("\n").each { |e| @tui.add_output(e); }; nil }
6
+ EV[:ask] = lambda { |i| i.split("\n").each { |e| @tui.add_output(i); }; nil }
7
+
8
+ # toychest.rb events
9
+ EV[:tarot] = lambda { |i| i.each { |e| @tui.add_output(e); }; nil }
10
+ EV[:duck] = lambda { |i| i.split("\n").each { |e| @tui.add_output(e) }; nil }
data/monsternet ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ if [[ "$1" == "--bork" ]]; then
4
+ rm attr.json uuid.txt
5
+ echo "127.0.0.1:9090" > peers.txt
6
+ else
7
+ # export NICK=$1;
8
+ ruby bin/tui $*;
9
+ fi
data/pages/index.erb ADDED
@@ -0,0 +1,5 @@
1
+ # Hello, <%= @peer %>!
2
+ The time is <%= Time.now.to_s %>
3
+ <% @params.each_pair do |k,v| %>
4
+ - <%= k %>: <%= v %>
5
+ <% end %>
data/pedicab.rb ADDED
@@ -0,0 +1,32 @@
1
+ @cab = Pedicab['monsternet']
2
+ @ask = ""
3
+
4
+
5
+ @methods << :pedicab
6
+ @help[:pedicab] = "the pedicab llm object library"
7
+ def pedicab
8
+ a = [
9
+ "#==[pedicab] The fasted way to get there.",
10
+ " - cab input => Create llm context with input.",
11
+ " - Pedicab['user'][input] => Create user llm context wih input.",
12
+ " - ask input => Process input within context.",
13
+ " - Pedicab['user'] << input => Process user input within context."
14
+ ]
15
+ puts(a)
16
+ end
17
+
18
+ @methods << :cab
19
+ @help[:cab] = "Load pedicab context."
20
+ def cab i
21
+ @ask = @cab[i]
22
+ puts("#--[cab] #{i}\n#{@ask = @cab[i]}")
23
+ return @cab.took
24
+ end
25
+
26
+ methods << :ask
27
+ @help[:ask] = "query pedicab."
28
+ def ask i
29
+ puts("#==[ASK] #{@ask}")
30
+ puts("#==[ask] #{i}", @ask = @cab << i)
31
+ return @cab.took
32
+ end
data/toychest.rb ADDED
@@ -0,0 +1,69 @@
1
+ @methods << :tarot
2
+ @help[:tarot] = "deal tarot cards."
3
+ def tarot q
4
+ puts("#--[tarot] Tarot reading about #{q}")
5
+ t = Toychest.tarot.reading(3)
6
+ a = []
7
+ [:past, :present, :future].zip(t).to_h.each_pair { |k,v| a << "- #{k}: #{v}" }
8
+ puts(a)
9
+ end
10
+
11
+ @methods << :duck
12
+ @help[:duck] = "query duckduckgo."
13
+ def duck q
14
+ puts("#--[duck] " + Toychest.duck[q][:text])
15
+ end
16
+
17
+ @methods << :roll
18
+ @help[:roll] = "roll dice for user"
19
+ def roll d, *f
20
+ x = DICE[f[0] || 'me'][d]
21
+ a = []
22
+ if f[0]
23
+ if f[1]
24
+ a << "#--[roll][#{f[0]}] #{f[1]}"
25
+ else
26
+ a << "#--[roll][#{f[0]}]"
27
+ end
28
+ a << x[:dice].map { |e| " - #{e}" }
29
+ a << "#--[roll][#{d}] >>> #{x[:roll]}"
30
+ a.flatten.each { |e| yo(f[0].to_s, e) }
31
+ return nil
32
+ else
33
+ puts("#--[dice][#{d}] >>> #{x[:roll]}", x[:dice].map { |e| "- #{e}" })
34
+ end
35
+ end
36
+
37
+ @methods << :nasa
38
+ @help[:nasa] = "query nasa"
39
+ def nasa *q
40
+ if q[0]
41
+ a, m = [], false
42
+ Toychest.nasa[q[0]].each_pair { |k,v|
43
+ if v.keys.include?(q[0])
44
+ a << "#==[nasa] #{k}:\n#{v[q[0]]}\n"
45
+ end
46
+ a << %[#--[nasa] #{k} - #{v.keys.join(", ")}]
47
+ }
48
+ puts(a)
49
+ else
50
+ a = []
51
+ Toychest.nasa[''].each_pair { |k,v|
52
+ a << %[#--[nasa] #{k} - #{v.keys.join(", ")}]
53
+ }
54
+ puts(a)
55
+ end
56
+ end
57
+
58
+ @methods << :zodiac
59
+ @help[:zodiac] = "read a horoscope"
60
+ def zodiac s, *u
61
+ z = ZODIAC['me'][s].values.map { |e| " - #{e}" }
62
+ if u[0]
63
+ yo(u[0].to_s, "#--[zodiac][#{s}]")
64
+ z.each { |e| yo(u[0].to_s, e) }
65
+ return nil
66
+ else
67
+ puts("#--[zodiac][#{s}]", z)
68
+ end
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monsternet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-09 00:00:00.000000000 Z
11
+ date: 2026-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: socket
@@ -138,7 +138,12 @@ files:
138
138
  - Rakefile
139
139
  - lib/monsternet.rb
140
140
  - lib/monsternet/version.rb
141
+ - monster.rb
142
+ - monsternet
143
+ - pages/index.erb
144
+ - pedicab.rb
141
145
  - sig/monsternet.rbs
146
+ - toychest.rb
142
147
  homepage: https://github.com/xorgnak/monsternet
143
148
  licenses:
144
149
  - MIT