530 |
531 |
531 save_config() |
532 save_config() |
532 elif command == 'die': |
533 elif command == 'die': |
533 check_admin (sender, ident, host, command) |
534 check_admin (sender, ident, host, command) |
534 quit() |
535 quit() |
535 elif command == 'testlog': |
536 elif command == 'convert': |
536 check_admin (sender, ident, host, command) |
537 if len(args) != 3 or args[1] != 'as': |
537 if len(args) < 1: |
538 raise logical_exception ("usage: .%s <value> as <valuetype>" % command) |
538 raise logical_exception ("usage: .%s <message...>" % command) |
539 |
539 chanlog (" ".join (args)) |
540 value = float (args[0]) |
|
541 valuetype = args[2] |
|
542 |
|
543 if valuetype in ['radians', 'degrees']: |
|
544 if valuetype == 'radians': |
|
545 radvalue = value |
|
546 degvalue = (value * 180.) / math.pi |
|
547 else: |
|
548 radvalue = (value * math.pi) / 180. |
|
549 degvalue = value |
|
550 |
|
551 self.privmsg (replyto, '%s radians, %s degrees (%s)' %(radvalue, degvalue, degvalue % 360.)) |
|
552 elif valuetype in ['celsius', 'fahrenheit']: |
|
553 if valuetype == 'celsius': |
|
554 celvalue = value |
|
555 fahrvalue = value * 1.8 + 32 |
|
556 else: |
|
557 celvalue = (value - 32) / 1.8 |
|
558 fahrvalue = value |
|
559 |
|
560 self.privmsg (replyto, '%s degrees celsius, %s degrees fahrenheit' %(celvalue, fahrvalue)) |
|
561 else: |
|
562 raise logical_exception ('unknown valuetype, expected one of: degrees, radians') |
540 # else: |
563 # else: |
541 # raise logical_exception ("unknown command `.%s`" % command) |
564 # raise logical_exception ("unknown command `.%s`" % command) |
542 |
565 |
543 # |
566 # |
544 # Print a ticket announce to appropriate channels |
567 # Print a ticket announce to appropriate channels |