File: crazy3.tcl

package info (click to toggle)
tkirc 1.202-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 500 kB
  • ctags: 40
  • sloc: tcl: 9,813; makefile: 64; sh: 3
file content (71 lines) | stat: -rw-r--r-- 2,101 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

# Command name: /crazy3
# Description:  Characters are displayed in different styles
#               (upper, lower, bold, underlined, reverse and some
#               characters will be exchanged through numbers).
#
# Date:         03.03.98
# Author:       Andreas Gelhausen, atte@gecko.north.de
#
# Changes:      03.03.98  Now this script can automatically be loaded
#                         from tkirc (~.tkirc/autoload/) and you
#                         don't need to change your tkircrc!
#
# Install:
#               1. copy this file to `~/.tkirc/autoload/crazy3.tcl'
#               2. reload your tkircrc or restart tkirc


proc on_command_crazy3 {window arguments} {
  set len [lLength "$arguments"]
  if {$len < 1} {
    print2crap "+++ Usage: /crazy3 \[( /msg | /notice | /describe ) <nick> | /me \] <message>"
    return
  }
  set command "" ; set newline ""
  if {[regexp -- {^(/msg|/notice|/describe) .*} "$arguments"]} {
    set command "[leftwords "$arguments" 2] "
    set arguments "[cutwords "$arguments" 2]"
  } elseif {[regexp -- {^(/me) .*} "$arguments"]} {
    set command "[leftwords "$arguments" 1] "
    set arguments "[cutwords "$arguments" 1]"
  }
  set next 0
  set vorher  "oIlEAST"
  set nachher "0113457"
  for {set i 0} {$i < [string length "$arguments"]} {incr i} {
    set char "[string index "$arguments" $i]"
    if {"$char" >= "A" && "$char" <= "z"} {
      if {$next == 0} {
	set char "[string tolower "$char"]"
      } else {
	set char "[string toupper "$char"]"
      }
      if {[expr round(rand())] == 0} {
	append newline "\x02"
      }
      if {[expr round(rand())] == 0} {
	append newline "\x1f"
      }
      if {[expr round(rand())] == 0} {
	append newline "\x16"
      }

      set j [string first "$char" "$vorher"]
      if {$j != -1} {
        set char [string index "$nachher" $j]
      }

      if {$next == 0} {
	append newline "[string tolower "$char"]"
      } else {
	append newline "[string toupper "$char"]"
      }
      set next [expr ($next-1)*(-1)]

    } else {
      append newline "$char"
    }
  }
  send2irc "$command$newline"
}