def start(self,name): if self.podminky(name) == False: util.chat(self.socket,"You dont have enough points to start game ConcernDoge") return util.chat(self.socket, "Guess number of Kappa from 1-25") self.generate() self.get()
def get(self): previousMilis = 0 while True: currentMillis = int(round(time.time() * 1000)) response = self.socket.recv(1024).decode("utf-8") if response == "PING :tmi.twitch.tv\r\n": self.socket.send("PONG :tmi.twitch.tv\r\n".encode()) print("PONG") continue self.username = re.search(r"\w+", response).group(0) self.message = CHAT_MSG.sub("", response) self.message = self.message.strip() if self.message not in self.emotes: continue if self.emotes[self.count] == self.message: util.chat( self.socket, "{} won 50 points PogChamp it was {}".format( self.username, self.message)) #self.points.addAI(self.username, 50) return else: if currentMillis - previousMilis > 1000: util.chat(self.socket, "{} not {}".format(self.username, self.message)) previousMilis = currentMillis
def start(self, name): if self.podminky(name) == False: util.chat(self.socket, "You dont have enough points to start game ConcernDoge") return util.chat(self.socket, "Guess emotes from: {}".format(self.emotesString)) self.generate() self.get()
def add(self,name,message): #adding points in chat way if self.checkPermission(name) == False: util.chat(self.socket, "PERMISSION DENIED ConcernDoge") return try: arr = message.split(' ') #arr[0] - command, #arr[1] - name, #arr[2] - amount print(arr[1]) arr[1] = arr[1].replace("\r\n","").lower() points = self.database.getPoints(arr[1]) self.database.setPoints(arr[1],str(points+int(arr[2]))) util.whisper(self.socket, "{} SUCCESS ConcernDoge".format(name)) except: util.whisper(self.socket, "{} ERROR ConcernDoge".format(name))
def main(): s = socket.socket() s.connect((c.HOST, c.PORT)) s.send(f"PASS {c.PASS}\r\n".encode("utf-8")) s.send(f"NICK {c.NICK}\r\n".encode("utf-8")) s.send(f"JOIN #{c.CHAN}\r\n".encode("utf-8")) logging.basicConfig(filename="./app.log", filemode="w+", format="%(asctime)s - %(levelname)s - %(message)s") chat_msg = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :") logging.debug(f"EpochBot: version {c.VERSION}") logging.debug("Logging has started!") util.chat(s, "Hello and welcome! Messages sent to this bot will be logged.") while True: response = s.recv(1024).decode("utf-8") if response == "PING :tmi.twitch.tv\r\n": s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8")) else: username = re.search(r"\w+", response).group(0) message = chat_msg.sub("", response) logging.info(response) if message.strip() == "!links": logging.info(f"{c.PERSONAL} {c.GITHUB}") util.chat(s, f"{c.PERSONAL} {c.GITHUB}") # code goes here if message.strip() == "!projects": logging.info(f"Chatversity API: {c.CHATVERSITY}\n") util.chat(s, f"Chatversity API: {c.CHATVERSITY}\n") if message.strip() == "!help": logging.info( f"!links - To see what I'm up to - !projects - Current projects I'm working on - !help - Displays this help page - !schudule - To see when I'm streaming" ) util.chat( s, f"!links - To see what I'm up to - !projects - Current projects I'm working on - !help - Displays this help page - !schudule - To see when I'm streaming" ) if message.strip() == "!schedule": logging.info( f"I'm going to try to get get on once a week during the weekend, typically around 9PM EST." ) util.chat( s, f"I'm going to try to get get on once a week during the weekend, typically around 9PM EST." )
def onQQMessage(bot, contact, member, content): # 当收到 QQ 消息时被调用 # bot : QQBot 对象,提供 List/SendTo/GroupXXX/Stop/Restart 等接口,详见文档第五节 # contact : QContact 对象,消息的发送者 # member : QContact 对象,仅当本消息为 群或讨论组 消息时有效,代表实际发消息的成员 # content : str 对象,消息内容 if content == '--version' and getattr(member, 'uin') == bot.conf.qq: bot.SendTo(contact, 'QQbot-' + bot.conf.version) msg = util.chat(contact,content) bot.SendTo(contact,msg)
def get(self): previousMilis = 0 while 1==1: currentMillis = int(round(time.time() * 1000)); response = self.socket.recv(1024).decode("utf-8") if response == "PING :tmi.twitch.tv\r\n": self.socket.send("PONG :tmi.twitch.tv\r\n".encode()) print("PONG") continue self.username = re.search(r"\w+", response).group(0) self.message = CHAT_MSG.sub("",response) self.message = self.message.strip() words = self.message.split() wordCount = Counter(words) if "!kill" in self.message and self.username == "korandi": print (self.username) util.chat(self.socket,"RIP. FeelsBadMan") return if "Kappa" not in self.message: continue if "Kappa" in self.message: if self.username == "korandi": continue if wordCount['Kappa'] == self.count: #self.points.userExists(self.username) util.chat(self.socket, "{} won 50 points! PogChamp".format(self.username)) #self.points.addAI(self.username,50) return True else: if currentMillis - previousMilis > 1000: util.chat(self.socket, "{} nope! Kappa".format(self.username)) previousMilis = currentMillis
def show(self,name): name = name.replace("\r\n","").lower() points = self.database.getPoints(name) strVar = "{}, you have {} doge points ConcernDoge".format(name,points) util.chat(self.socket, strVar)