I have the following code:
import ch
import re
import sys
def doMath(desIn):
desOut = desIn+2
return desOut
class bot(ch.RoomManager):
def onMessage(self, room, user, message):
try:
cmd, args = message.body.split(" ", 1)
except:
cmd, args = message.body, ""
if cmd=="!math":
doMath(3)
print(desOut)
I am using ch.py to run a bot in a Chatango chat room. It is designed to perform a certain task when a user sends out a specific message. In this case when a user sends the message of "!math"
, I would like for it to call the doMath function with an input (desIn
), perform the math operation I coded, and then return an output (desOut
). In this case, it should return 5. My code runs all the way through, but it does not seem to print the last line that I wrote. Is it possible to return the output into the bot
class I have?
By request, why does this not work?
def doMath(desIn):
desOut = desIn+2
return desOut
class A:
doMath(3)
print(desOut)