Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added two new commands to toggle ripecheck on or off and to clear ban…

… list

- .ripetoggle will toggle ripecheck on or off for one or more channels
- .ripeclearban clear all bans set by ripecheck for one or more channels
- Updated .help texts
  • Loading branch information...
commit d1d773c390ca89bfc72701ce88c80c70402cb61f 1 parent e95abbb
Stefan Wold authored

Showing 1 changed file with 112 additions and 8 deletions. Show diff stats Hide diff stats

  1. +112 8 ripecheck.tcl
120 ripecheck.tcl
@@ -139,12 +139,14 @@ package require http
139 139 # Bindings
140 140 bind join - *!*@* ::ripecheck::onJoin
141 141 bind dcc -|- testripecheck ::ripecheck::test
142   -bind dcc m|ov +ripetopdom ::ripecheck::addTopDom
143   -bind dcc m|ov -ripetopdom ::ripecheck::delTopDom
144   -bind dcc m|ov +ripetopresolv ::ripecheck::addTopResolve
145   -bind dcc m|ov -ripetopresolv ::ripecheck::delTopResolve
146   -bind dcc m|ov ripeconfig ::ripecheck::config
147   -bind dcc m|ov ripescan ::ripecheck::dccRipeScan
  142 +bind dcc m|o +ripetopdom ::ripecheck::addTopDom
  143 +bind dcc m|o -ripetopdom ::ripecheck::delTopDom
  144 +bind dcc m|o +ripetopresolv ::ripecheck::addTopResolve
  145 +bind dcc m|o -ripetopresolv ::ripecheck::delTopResolve
  146 +bind dcc m|o ripeconfig ::ripecheck::config
  147 +bind dcc m|o ripescan ::ripecheck::dccRipeScan
  148 +bind dcc m|o ripetoggle ::ripecheck::dccToggle
  149 +bind dcc m|o ripeclearban ::ripecheck::dccClearBan
148 150 bind dcc -|- ripesettings ::ripecheck::settings
149 151 bind dcc -|- help ::stderreu::help
150 152 bind pub -|- !ripecheck ::ripecheck::pubRipeCheck
@@ -1379,6 +1381,91 @@ namespace eval ::ripecheck {
1379 1381 ::ripecheck::writeSettings
1380 1382 }
1381 1383
  1384 + # Function to toggle ripecheck on and off. Also gives the ability to clear the ban list when toggled off.
  1385 + proc dccToggle { nick idx arg } {
  1386 + if {[llength [split $arg]] < 2} {
  1387 + putdcc $idx "\002RIPECHECK\002: Missing arguments"
  1388 + ::stderreu::ripetoggle $idx
  1389 + }
  1390 +
  1391 + set toggle [string tolower [lindex $arg 0]]
  1392 + set channel [lindex $arg 1]
  1393 + set clearBan [string tolower [lindex $arg 2]]
  1394 +
  1395 + if {!($toggle == "on" || $toggle == "off")} {
  1396 + putdcc $idx "\002RIPECHECK\002: Invalid toggle command! Allowed values are 'on' or 'off'"
  1397 + return
  1398 + }
  1399 +
  1400 + # Iterate over all channels the bot is on
  1401 + if {$channel == "*"} {
  1402 + foreach chan [channels] {
  1403 + ::ripecheck::toggleRipecheckChan $idx $toggle $chan
  1404 + if {$clearBan == "-clearban" && $toggle == "off"} {
  1405 + ::ripecheck::clearChannelBanList $chan
  1406 + putdcc $idx "\002RIPECHECK\002: Bans set by ripecheck has been cleared from '$chan'"
  1407 + }
  1408 + }
  1409 + } elseif {[validchan $channel]} {
  1410 + ::ripecheck::toggleRipecheckChan $idx $toggle $channel
  1411 + if {$clearBan == "-clearban" && $toggle == "off"} {
  1412 + ::ripecheck::clearChannelBanList $channel
  1413 + putdcc $idx "\002RIPECHECK\002: Bans set by ripecheck has been cleared from '$channel'"
  1414 + }
  1415 + } else {
  1416 + putdcc $idx "\002RIPECHECK\002: Invalid channel '$channel'"
  1417 + }
  1418 + }
  1419 +
  1420 + # Sets +/-ripecheck on channel
  1421 + proc toggleRipecheckChan { idx toggle channel } {
  1422 + if {$toggle == "on"} {
  1423 + channel set $channel +ripecheck
  1424 + putdcc $idx "\002RIPECHECK\002: Enabled (+) ripecheck for channel '$channel'"
  1425 + } else {
  1426 + channel set $channel -ripecheck
  1427 + putdcc $idx "\002RIPECHECK\002: Disabled (-) ripecheck for channel '$channel'"
  1428 + }
  1429 + }
  1430 +
  1431 + # Dcc function to clear bans set by ripecheck for supplied channel(s)
  1432 + proc dccClearBan { nick idx arg } {
  1433 + if {[llength [split $arg]] < 1} {
  1434 + putdcc $idx "\002RIPECHECK\002: Missing channel argument"
  1435 + ::stderreu::ripeclearban $idx
  1436 + return
  1437 + }
  1438 +
  1439 + set channel [lindex $arg 0]
  1440 +
  1441 + if {$channel == "*"} {
  1442 + foreach chan [channels] {
  1443 + ::ripecheck::clearChannelBanList $chan
  1444 + putdcc $idx "\002RIPECHECK\002: Bans set by ripecheck has been cleared from '$chan'"
  1445 + }
  1446 + } elseif {[validchan $channel]} {
  1447 + ::ripecheck::clearChannelBanList $channel
  1448 + putdcc $idx "\002RIPECHECK\002: Bans set by ripecheck has been cleared from '$channel'"
  1449 + } else {
  1450 + putdcc $idx "\002RIPECHECK\002: Invalid channel"
  1451 + }
  1452 + }
  1453 +
  1454 + # Function to clear all bans for specified channel set by ripecheck
  1455 + proc clearChannelBanList { channel } {
  1456 + foreach ban [banlist $channel] {
  1457 + if {[lindex $ban 5] == "ripecheck"} {
  1458 + set banmask [lindex $ban 0]
  1459 +
  1460 + if {[killchanban $channel $banmask]} {
  1461 + ::ripecheck::debug "Removed ban '$banmask' from '$channel'"
  1462 + } else {
  1463 + putlog "ripecheck: Failed to clear the ban list for '$channel'"
  1464 + }
  1465 + }
  1466 + }
  1467 + }
  1468 +
1382 1469 # Add top domain to channel and write settings to file
1383 1470 proc addTopDom { nick idx arg } {
1384 1471 if {[llength [split $arg]] != 2} {
@@ -1515,7 +1602,7 @@ namespace eval ::ripecheck {
1515 1602 namespace eval ::stderreu {
1516 1603 variable helpfuncs
1517 1604
1518   - dict set ::stderreu::helpfuncs ripecheck [list ripecheck +ripetopresolv -ripetopresolv +ripetopdom -ripetopdom ripescan ripesettings ripeconfig testripecheck]
  1605 + dict set ::stderreu::helpfuncs ripecheck [list ripecheck +ripetopresolv -ripetopresolv +ripetopdom -ripetopdom ripescan ripesettings ripeconfig ripetoggle ripeclearban testripecheck]
1519 1606
1520 1607 proc ripecheck { idx } {
1521 1608 putidx $idx "### \002ripecheck v$::ripecheck::version\002 by Ratler ###"; putidx $idx ""
@@ -1542,6 +1629,8 @@ namespace eval ::stderreu {
1542 1629 ::stderreu::ripescan $idx
1543 1630 ::stderreu::ripesettings $idx
1544 1631 ::stderreu::ripeconfig $idx
  1632 + ::stderreu::ripetoggle $idx
  1633 + ::stderreu::ripeclearban $idx
1545 1634 ::stderreu::testripecheck $idx
1546 1635 putidx $idx "### \002help ripecheck\002"
1547 1636 putidx $idx " This help page you're currently viewing"
@@ -1607,10 +1696,24 @@ namespace eval ::stderreu {
1607 1696 putidx $idx " \002*NOTE*\002:"
1608 1697 putidx $idx " To completely remove an option from the configuration leave \[value\] blank, ie .ripeconfig msgcmds"
1609 1698 }
  1699 +
  1700 + proc ripetoggle { idx } {
  1701 + putidx $idx "### \002ripetoggle <on|off> <#channel|*> \[-clearban\]\002"
  1702 + putidx $idx " Enable (+) or disable (-) ripecheck for one or all channels."
  1703 + putidx $idx " If the option '-clearban' is used with the toggle option 'off' all bans set by ripecheck will be removed"
  1704 + putidx $idx " Example: .ripetoggle off #channel -clearban"
  1705 + }
  1706 +
  1707 + proc ripeclearban { idx } {
  1708 + putidx $idx "### \002ripeclearban <#channel|*>\002"
  1709 + putidx $idx " Clear all bans set by ripecheck for one or all channels"
  1710 + }
  1711 +
1610 1712 proc ripesettings { idx } {
1611 1713 putidx $idx "### \002ripesettings\002"
1612 1714 putidx $idx " View current settings"
1613 1715 }
  1716 +
1614 1717 proc testripecheck { idx } {
1615 1718 putidx $idx "### \002testripecheck <channel> <host>\002"
1616 1719 }
@@ -1618,7 +1721,8 @@ namespace eval ::stderreu {
1618 1721 proc ripecheckdefault { idx } {
1619 1722 putidx $idx "\n\nripecheck v$::ripecheck::version commands:"
1620 1723 putidx $idx " \002+ripetopresolv -ripetopresolv +ripetopdom -ripetopdom\002"
1621   - putidx $idx " \002ripesettings ripescan ripeconfig testripecheck\002"
  1724 + putidx $idx " \002ripesettings ripescan ripeconfig ripetoggle\002"
  1725 + putidx $idx " \002ripeclearban testripecheck\002"
1622 1726 }
1623 1727
1624 1728 proc help { hand idx arg } {

0 comments on commit d1d773c

Please sign in to comment.
Something went wrong with that request. Please try again.