a small collection of personal scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.6KB

  1. use strict;
  2. use warnings;
  3. use utf8;
  4. use Encode qw(encode decode);
  5. weechat::register ("subs", "shmibs", "0.1", "GPL",
  6. "auto-substitute substrings with 'hard to type' alternatives",
  7. "", "");
  8. weechat::hook_modifier("input_text_for_buffer", "catch_send", "");
  9. my %naive_subs = (
  10. qr':bot:' => '<|°_°|>',
  11. qr':shrug:' => '┐(¯-¯)┌',
  12. qr':shrug2:' => '┐(\'~`;)┌',
  13. qr':shrug3:' => '┐(\'_`;)┌',
  14. qr':wat:' => '(゚-゚)',
  15. qr':jii:' => '(T_T)',
  16. qr':grr:' => '\(`Д´)/',
  17. qr':shout:' => '(≧ロ≦)',
  18. qr':woot:' => '\(≧▽≦)/',
  19. qr':sigh:' => '(´・ω・`)',
  20. qr':sad:' => '(´;ω;`)',
  21. qr':squee:' => '(⁎>ᆺ<)',
  22. qr':squee2:' => '(⋈◍>◡<◍)',
  23. qr':gah:' => '(。>﹏<。)',
  24. qr':bleh:' => '(*´﹃`*)',
  25. qr':ryoukai:' => '( ̄^ ̄)ゝ リョウカイ!',
  26. qr':raja:' => '(`_´)ゞラジャー',
  27. qr':yatta:' => '٩(ˊᗜˋ*)و✧*。',
  28. qr':omoi:' => '( ´-` ).。oO',
  29. qr':panch:' => '((꜆꜄•ω•)꜆꜄꜆オラオラオラオラ',
  30. qr':yosi:' => '(๑•̀ㅂ•́)و✧',
  31. qr':katu' => '٩(`^´๑ )۶三٩( ๑`^´)۶',
  32. qr':tehe:' => '( ◜ ▿ ◝ )テヘヘ',
  33. qr':gitlub:' => '₍₍♡◟( ˘•ω•˘)ว ⁾⁾≡♡≡♡',
  34. qr':baibai:' => '(∗ ◜ω◝ ∗)◞ ⁾⁾',
  35. qr':tunes:' => '♪(๑ᴖ◡ᴖ๑)♪',
  36. qr':shokku:' => '(0ㅁ0)‼',
  37. qr':ndnd:' => '(。-ω-ヾ(∀`。)',
  38. qr':pyon:' => '⋆⸜(*^꒳^* )⸝ピョンピョンピョンピョン',
  39. qr'\(h\)' => '♥',
  40. qr'\(s\)' => '★',
  41. qr'\(n1\)' => '♪',
  42. qr'\(n2\)' => '♫',
  43. qr'\(inf\)' => '∞',
  44. qr'\(theta\)' => 'θ',
  45. qr'\(lambda\)' => 'λ',
  46. qr'\(delta\)' => 'δ',
  47. qr'\(sigma\)' => 'σ',
  48. qr'\(epsilon\)' => 'ε',
  49. qr'\(phi\)' => 'φ',
  50. qr'\(mu\)' => 'μ',
  51. qr'\(omega\)' => 'ω',
  52. qr'\(c\)' => '©',
  53. qr'\(deg\)' => '°',
  54. qr'\(r\)' => '®',
  55. qr'\(tm\)' => '™',
  56. # sound-making
  57. qr'\*\*(\**.+?\**)\*\*' => "\x{02}" . '*$1* *$1*' . "\x{02}",
  58. # greentext
  59. qr'^(>.*)' => "\x{03}03" . '$1',
  60. qr'^\\(>.*)' => '$1',
  61. );
  62. my %fullword_subs = (
  63. qr'for' => 'för',
  64. qr'(?:small|smol)' => 'smöl',
  65. qr'(?:small|smol)(s|er|est)' => 'smöl$1',
  66. qr'(?:slow|slo)' => 'slö',
  67. qr'(?:slow|slo)(s|er|est|ing|ed)' => 'slö$1',
  68. );
  69. sub catch_send {
  70. my ($data, $modifier_name, $buffer, $rval) = @_;
  71. my ($key, $val);
  72. $rval = decode('UTF-8', $rval);
  73. while( ($key, $val) = each %naive_subs) {
  74. $val =~ s/\\/\\\\/g;
  75. $val = "\"$val\"";
  76. $rval =~ s/$key/$val/gee;
  77. }
  78. while( ($key, $val) = each %fullword_subs) {
  79. $val =~ s/\\/\\\\/g;
  80. $val = "\"$val\"";
  81. $rval =~ s/^$key$/$val/gee;
  82. $rval =~ s/^$key(?=[^\w])/$val/gee;
  83. $rval =~ s/(?<=[^\w])$key$/$val/gee;
  84. $rval =~ s/(?<=[^\w])$key(?=[^\w])/$val/gee;
  85. }
  86. return encode('UTF-8', $rval);
  87. }