Zeige Nachrichten im Terminal (wie früher)
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -3,4 +3,5 @@ config.lua
 | 
			
		||||
tg
 | 
			
		||||
tmp/*
 | 
			
		||||
miku/plugins/licht.lua
 | 
			
		||||
Bot-Kommandoliste.txt
 | 
			
		||||
Bot-Kommandoliste.txt
 | 
			
		||||
msg.txt
 | 
			
		||||
							
								
								
									
										37
									
								
								miku/bot.lua
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								miku/bot.lua
									
									
									
									
									
								
							@@ -49,7 +49,7 @@ function bot:init(config) -- The function run when the bot is started or reloade
 | 
			
		||||
		if p.init then p.init(self, config) end
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	print('Bot wurde erfolgreich gestartet!\n@' .. self.info.username .. ', AKA ' .. self.info.first_name ..' ('..self.info.id..')')
 | 
			
		||||
	print('Mikubot wurde erfolgreich gestartet!\n@' .. self.info.username .. ', AKA ' .. self.info.first_name ..' ('..self.info.id..')')
 | 
			
		||||
 | 
			
		||||
	-- Set loop variables
 | 
			
		||||
	self.last_update = self.last_update or 0 -- Update offset.
 | 
			
		||||
@@ -63,6 +63,41 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec
 | 
			
		||||
    -- vardump(msg)
 | 
			
		||||
	-- Cache user info for those involved.
 | 
			
		||||
	
 | 
			
		||||
	-- print messages
 | 
			
		||||
	msg_time = convert_timestamp(msg.date, '[%H:%M:%S] ')
 | 
			
		||||
	
 | 
			
		||||
	if msg.chat.title then
 | 
			
		||||
	  from_chat = ' \27[36m'..msg.chat.title..':\27[0m '
 | 
			
		||||
	else
 | 
			
		||||
	  from_chat = ''
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	if msg.from.first_name then
 | 
			
		||||
	  name1 = '\27[1m\27[31m'..msg.from.first_name..'\27[0m'
 | 
			
		||||
	else
 | 
			
		||||
	  name1 = ''
 | 
			
		||||
	end
 | 
			
		||||
	if msg.from.last_name then
 | 
			
		||||
	  name2 = '\27[1m\27[31m'..msg.from.last_name..'\27[0m'
 | 
			
		||||
	else
 | 
			
		||||
	  name2 = ''
 | 
			
		||||
	end
 | 
			
		||||
	if msg.from.username then
 | 
			
		||||
	  name3 = ' (@'..msg.from.username..'\27[0m)'
 | 
			
		||||
	else
 | 
			
		||||
	  name3 = ''
 | 
			
		||||
	end
 | 
			
		||||
	full_name = name1..' '..name2..name3
 | 
			
		||||
	
 | 
			
		||||
	if msg.text then
 | 
			
		||||
	  user_msg = msg.text..'\27[0m'
 | 
			
		||||
	else
 | 
			
		||||
	  user_msg = ''
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
    full_message = msg_time..from_chat..full_name..' >>> '..user_msg
 | 
			
		||||
	print(full_message)
 | 
			
		||||
	
 | 
			
		||||
	if msg.date < os.time() - 5 then return end -- Do not process old messages.
 | 
			
		||||
 | 
			
		||||
	msg = utilities.enrich_message(msg)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user